Is there any way to turn off Resharper 7 auto formatting? - visual-studio-2010

This has been driving me crazy, I've tried Resharper support with no solution, but wondered if anyone out there has experienced this.
When I update an existing method and hitting the curly brace or semi-colon, I am getting a double indent:
public void abc(int a, int b) {
var c; // <- after hitting return after the curly brace
var d;
var e;
}
Is there any way to completely turn off Resharper formatting? Or at least fix this problem? I've looked in the Resharper->Code Editing->C# but didn't find anything that worked.
PS - This is on VS 2010

Both ReSharper and Visual Studio have auto-formatting. But in C# they are usually triggered by pressing ; or }, not by carriage return, so either you describe your actions wrong or you've hit some kind of bug.
To turn off ReSharper auto-formatting, go to ReSharper | Options -> Environment | Editor and turn off "Auto-format on semicolon" and "Auto-format on closing brace". If that won't help against your bug you may want also to turn off "Auto-insert closing brace" on the same page.
To turn off Visual Studio auto-formatting, go to Tools | Options -> Text Editor | C# | Formatting | General and turn off "Automatically format ... " options.
But even without auto-format formatting would still be done on refactorings and quick fixes, so you may want to tune formatting options (besides or instead of turning off auto-format). First of all, go to Tools | Options -> Text Editor | C# | Tabs. Make sure that tab size and indent size are equal (ReSharper doesn't support different values here) and have correct value. Also choose between Insert spaces and Keep tabs. Then go to ReSharper | Options -> Code Editing | C# | Formatting style | Braces layout. Judging by your code, you prefer K&R style. So select "K&R style" value for the first 6 options on this page. These are most important settings, but you may also want to look at other formatting style settings to better adjust them for your style.

Related

Unexpected opening curly bracket indentation

If I type if (true) Enter
the cursor will be indented like
and if I continue with { Enter }, I will get a brace layout like
Why?
I expect the braces to be like
In resharpers Braces layout section I have setup braces layout to be At next line (BSD style).
In visual studios options, going into Text Editor, C#, Code Style, Formatting, Indentation I have the checkbox Indent open and close braces checkbox unchecked.
How is it possible with two separate options sections for code style, both Visual Studio and Resharper? Who wins?
I think the solution is to:
go to Visual Studio Options -> Text Editor -> All Languages -> Tabs and set Indenting to Block, then
go to ReSharper Options -> Environment -> Editor -> Editor Behavior and make sure Smart Indent on Enter is unchecked.

How do I set different colors for different kind of 'comments' in Visual Studio Code?

Hi, I have these settings for comments in Visual Studio 2017:
1) two comment bars '//' (dark green in the image) to indicate 'normal comments'.
2) three comment bars '///' (light green) for special notes and titles.
I find this technique very useful to mantain a clearer code, and I would like to apply the same logic (having similar color settings) in Visual Studio Code.
But I can't figure it out how to do it.
No. You got it wrong. Tripple slash comment is for documentation generation. It is NOT meant for coloring. When it is used with the proper tags, the compiler autogenerates the relative documentation/tooltips:
<summary>Open the connection.</summary>
public void Open()
{
.
.
.
}
Later, when one is accessing the Open() method in Visual Studio, in addition to the intellisense, a tooltip is shown, with the text "Opens the connection."
AFAIK, there is no such thing as a "coloring of a comment". Nor there are "different comments". What do you mean by that?
If you're looking for a way to order your commenes, you might find useful, to structurize them by using a "comment token", thus making the comment appear on the Visual Studio's Task List. Also, you can create your own tokens. From the menu, open the Tools -> Options dialog; choose Environment => Task List from the list on the left.
So somewhere in you code you might do this:
// TODO: Either delete or uncomment the next line.
// settings.decorared = false
Then you'll see the TODO note in your Task List, but not the //settings.decorated.
Hint: To display the Task List press Ctrl+\,T.
You can change the comment color by going to:
Tools | Options | Environment | Fonts and Colors | Comment

How can I make Resharper wrap very long lines properly?

Resharper's code formatting is generally fine, but it seems completely broken when dealing with very long lines. For example look at this piece of code:
I do want some kind of line wrapping, but it should look ahead and indent less if necessary to avoid ridiculous amounts of line breaks. Something like this would be great:
Is there any way to make Resharper do this?
Alex Berezoutsky of Jetbrains has suggested to turn off "Indent array, object and collection initializer" checkbox in the "ReSharper | Options | Languages | C# | Formatting Style | Other" dialog. It's not ideal IMO for shorter lines, but it does look much better on very long code lines.
I guess it's the best workaround for this problem at the current time.
I admittedly haven't plugged your code into my IDE to try it so I don't have exact setting values for you, but have a go at tweaking the line wrapping options in R# options.
Go to Resharper | Options
Under Languages expande C# and then Formatting Style, click on Line Breaks and Wrapping
Review the settings in that category

Over-enthusiastic Intellisense in VS2010 - can I tweak it?

Since I have upgraded from VS2008 to VS2010, I've been having an increasingly infuriating battle with the Intellisense.
For example, when specifying CSS styles, when I press Enter to start an new line, Intellisense (appropriately) lists available Styles to me. And if I select color and then type ':', it presents a list of color presets - often helpful. However, if I type in a space (I like them for readability) or if I type '#' to enter RGB values, it selected the default Intellisense selection, in this case inherits.
Another example is in an ASP.NET page - say I am concatenating strings, I type myString =, I get an Intellisense pop-up. If I type space or '"' (to enter a literal) or '.' (so select a property or method within a WITH block), the Intellisense selects the first entry in the list.
I can dismiss the Intellisense pop-ups with escape but it makes it incredibly slow to code.
This behaviour is different to my VS2008 set-up. I can't seem to find any way to configure Intellisense to behave differently... I really only want it to select and Intellisense entry when I type or ... at least, certainly not when I type '"' or ' ' or '.'!
Problem solved:
Being the idiot that I am, I hadn't properly checked for extensions; when I did, I found I had the Intellisense Presenter extension installed, and digging further it appear that my experience is not unique. It's a promising extension, but is currently unusable in this state.
This isn't normal. Start with Tools + Import and Export, select Reset all Settings. Next step is to run devenv.exe with the /safemode command line argument so it runs with all add-ins disabled.

Code template's indentation is buggy for code behind files in VS2005?

Not sure if anyone else has come across this yet. I like to use a an indent of 2 or 3 and not the default 4 for visual studio because i find my code runs a bit far to the right and I prefer to not code over column 80 for readability's sake. When I change the indent and tabs to 2 using tools >> options >> Text Editor >> C# >> tabs and also set it to "keep tabs" then new classes created are fine. BUT if I create a new ASPX page with a code behind page, the code behind page's initial code keeps a 4 space indent although i specified 2. I have to format the document (a quick ctrl e, d) but it is still irritating. Anyone else come across this?
Try setting Tools -> Options -> Text Editor -> All Languages -> Tabs instead of C# -> Tabs.
Alternatively try a different font or try breaking your code up into smaller pieces by extracting methods via the Visual Studio built-in refactoring tools, etc.
Just had a look now. All languages are already set. I could break up my code further but don't want it to get into spaghetti code. I like my methods do a logical unit of work :)

Resources