ReSharper 2017.1 Help

Indentation Style

Indentation is one of the most important aspects of formatting style - properly indented code will be readable even if other formatting is inconsistent. ReSharper helps you configure and maintain proper indentation in many ways.

In this topic:

Sources of indentation settings

By default, ReSharper uses Visual Studio preferences for tabs and indents (Tools | Options | Text Editor | All Languages | Tabs and Tools | Options | Text Editor | [language] | Tabs). However, if you prefer to share formatter preferences with your team using ReSharper's layered settings, you can clear the Use indent style and size from Visual Studio check box on the Code Editing | [language] | Formatting Style | Tabs and Indents page of ReSharper options, and then configure and save your indentation preferences to the team-shared setting layer.

If there are .editorconfig files that affect the current file, the indent_size and indent_style properties will override both Visual Studio and ReSharper indentation settings. If you want ReSharper to ignore EditorConfig styles, clear the corresponding check box on the Code Editing | General Formatter Style page of ReSharper options.

Auto-detecting indents

When you reformat a part of code in a file or when code is auto-formatted on editing or pasting, ReSharper can calculate and apply indentation based on the existing indents in that file. By default, auto-detecting indents is disabled but you can enable it on the Code Editing | General Formatter Style page of ReSharper options.

You can also toggle the auto-detecting indents preference and view its status in the File Formatting Info window.

Note that ReSharper will NOT auto-detect indents if you reformat the whole file or multiple files, or if there are .editorconfig files that affect the current file.

Note also, that if you enable auto-detecting indents, or indents in ReSharper settings, or if you have .editorconfig files that affect the current file, then indents from these sources are temporary saved in Visual Studio settings while the affected file is open and active in Visual Studio.
You should take this into account if synchronization of Visual Studio settings is enabled.

Last modified: 12 October 2017