ReSharper 2017.2 Help

General Formatter Style

ReSharper | Options | Code Editing | General Formatter Style

ReSharper's formatting options are configurable in a very flexible way and for each supported language separately. While this page provides a few general settings, the language-specific pages (Code Editing | [Language] | Formatting Style) allow you to fine-tune code formatting according to your coding standards and practices.

The options that you configure on this page apply in the following cases:

ItemDescription
How to indent multi-language files These options define how to indent injected languages in a code file. For example, JavaScript in an HTML file.
  • Indent all languages equally using settings from main language (as Visual Studio does)
    When this option is selected, ReSharper uses similar indents for all injected languages.
  • Indent each language using its own settings (as ReSharper 7 and older did). When this option is selected, ReSharper uses indents defined for each language in the corresponding settings pages: Code Editing | [Language] | Formatting Style.
Auto-detect indent size and style

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.

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.

How to align when tabs are used for indents This preference lets you choose whether and how to use tabs when aligning multiple constructs - for example, when function parameters on multiple lines are aligned by the first parameter:
void foo(int firstParameter, int secondParameter) { }
  • Use spaces (recommended, looks aligned on any tab size)
    When this option is selected, ReSharper uses tabs for indents and spaces for alignment:
    /help/img/dotnet/2017.2/general_formatter_style1.png
    This is recommended option because code aligned with second and third options may lose alignment when viewed in an editor with a different tab size.
  • Only use tabs (inaccurate)
    When this option is selected, ReSharper uses tabs for both indents and alignment, which may not result in precise alignment:
    /help/img/dotnet/2017.2/general_formatter_style2.png
  • Mix tabs and spaces for optimal fill
    When this option is selected, ReSharper uses tabs for both indents and alignment adds necessary spaces for precise alignment.
    /help/img/dotnet/2017.2/general_formatter_style3.png
Enable EditorConfig support

EditorConfig is a configuration file convention that is used to define and maintain consistent code styles between team members working on the same code as well as between different editors and IDEs that they might use. The styles are saved in INI-like files named .editorconfig, where section names are file masks and properties inside a section define code styles for files matching that masks.

Use this check box to make ReSharper respect code formatting styles defined in EditorConfig configuration files. For more information, see Using EditorConfig.
Enable Clang-Format styles support Clang-Format is a widely-used C++ code formatter. As it provides an option to define code style options in YAML-formatted files — named .clang-format or _clang-format — these files often become a part of your project where you keep all code style rules.
Use this check box to make ReSharper respect code formatting styles defined in Clang-Format configuration files. For more information, see Using Clang-Format.
Show indicator in status bar when EditorConfig is present If this option is enabled, ReSharper displays the /help/img/dotnet/2017.2/ThemedIcon.ProjectPropertiesFile.Screen.[Gray].png icon in the bottom right part of the Visual Studio window if there are .editorconfig files that apply to the current solution. You can double-click this icon to study active EditorConfig configurations in the File Formatting Info window.
Last modified: 12 October 2017

See Also

Concepts: