Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to turn off Resharper 7 auto formatting?

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

like image 518
Mark Kadlec Avatar asked May 23 '13 16:05

Mark Kadlec


1 Answers

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.

like image 194
Dmitry Osinovskiy Avatar answered Oct 12 '22 00:10

Dmitry Osinovskiy