I found that I can apply code formatting rules by CTRL+K+D in Visual C++. But how to edit these rules?
I need somehow define this rule:
transform
from:
if (i=1) {do_something;}
to:
if (i=1)
{
do_something;
}
Where and how I can setup this?
To get
if (i=1)
{
do_something;
}
(which I find rather unconventional) you need to indent braces
and move control blocks to a new line
(Screenshots from Visual Studio 2013. I hope Visual Studio 2010 has the same settings.)
Related
in Visual studio when i hit enter from ternary expression ?? in constructor i get lines break like this:
But Rider doing breaking for ternaries like this:
How to set up braking lines in Rider for ternaries like it works in Visual Studio?
I think you can't configure in the same way as VS. The wrapping of the ternary lines indents with the default Indent size (by default is set to 4). So in other word it's a fixed size and not "dynamic" like it's for VS int that situation. Maybe it's a feature you could request at JetBrains Rider Support page.
In our team we are using TSLint with "jsx-curly-spacing": [ true, "always" ]. Half our team uses VS Code and when they use Code Formatting they have this done automatically. However if i press
Ctrl+E, Ctrl+D to format the entire document the spacing is removed.
How I would like it to be:
<div className={ classes.root }>
How it turns out:
<div className={classes.root}>
I have looked at the settings but I can't find any for brackets.
I'm using the new Visual Studio Enterprise 2017 15.5.3.
VS Code has this automatically it seems and they can toggle it using these settings:
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": true,
VS Code - Code Formatting space before curly braces
Not a complete fix but it could be something. Since we are using TSLint and have TypeScript Analyzer installed I can right click the project or a single file/folder and then select Fix TypeScript Analyzer Errors If Possible. This solved my problem but it is an extra step.
https://marketplace.visualstudio.com/items?itemName=RichNewman.TypeScriptAnalyzer
I also added a feature request to Visual Studio for this.
https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/32878903-code-formatting-typescript-and-javascript-spac
Is there a way to create custom shorthand's in Visual Studio 2017.
Just like ctor or prop?
I would like to create a shorthand for unit-tests, to just type in for instance test and then having a predefined function to edit like:
public void Method_Condition_Expected()
{
// Arrange
// Act
// Assert
}
As #Peter B has suggested for Visual Studio itself you can do it with Snippet Designer (Tools->Code Snippets Manager).
I found out right now, that my installed Tool ReSharper (2016.3) has an option to create so-called Live-Template's.
With that, I can create a Template like this:
public void $Method$_$Condition$_$Expected$()
{
// Arrange
// Act
// Assert
}
The nice part is now, that i can tab through Method,Condition and Expected and overwrite the values.
How to use: Mark a Code-Area such like the code Above in Visual Studio then click on Resharper->Tools->Create Live Template from Selection->Create and Edit.
Now wrap code-areas for tabing through with $ for instance like $Method$ and give a shortcut name such like test.
I hope this helps somebody else as well.
For a closer Comparision between Visual Studio Snippet Manager and Resharper Live Templates see Difference between Live Template and Visual Studio Snippet
In Visual Studio, is it possible to create hyperlinks inside source files that jump to a specific line of a file? I want to create a link to a specific line, like this:
// [[#DoStuff|Clicking here will take you to the method "doStuff."]]
//
//
//
//
// #DoStuff
//clicking the hyperlink should jump to the line above.
function doStuff(){
}
Is there any way to create hyperlinks in the comments that will jump to a specific method?
It looks like there's a Visual Studio plugin called HyperAddin that can do this. Unfortunately, it looks like it's only available for Visual Studio 2005 and Visual Studio 2008.
I want to HighLight Indentation in Visual Studio IDE 2005.
I want to replace space with periods(.)
for e.g:- This is what I want
main
.{
..Print("hello World");
.}
The only built in thing that's similar is Edit|Advanced|View Whitespace (Ctrl-E, S)
CodeRush Express, a free download also does stuff in this direction (though it might not work in 2005?)