ReSharper 2024.3 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:

How to indent multi-language files

These options define how to indent injected languages in a code file — for example, how to indent JavaScript code 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 the rest of 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.

Use this checkbox to enable or disable this behavior.

Provide ReSharper indent settings to Visual Studio

If this option is enabled, ReSharper will provide indenting preferences (both from its layer-based settings and from supported configuration files) to Visual Studio, so that they are used when the code is created or transformed using Visual Studio features.

This option is disabled by default because ReSharper overrides almost all Visual Studio's coding assistance features with its own features.

Default line ending style

ReSharper allows you to use custom line endings in your code, and you can use this selector to choose which line ending style should be used.

Enforce line ending style on full reformat

When this option is disabled, the selected line ending style will only apply when new files are created with ReSharper features (for example, file templates or refactorings).

When this option is enabled ReSharper will also apply the selected line ending style when you reformat code or run code cleanup on a file, project, or solution.

Code style configuration files

Read code style from .editorconfig files

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 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 those masks.

Use this checkbox to make ReSharper respect code formatting styles defined in EditorConfig configuration files. For more information, refer to Use EditorConfig.

Write current style to .editorconfig

Click this button to export code styles from ReSharper settings to an .editorconfig file.

Edit .editorconfig interactively

Click this button to configure a new or existing .editorconfig file using ReSharper options user interface.

Read code style from .clang-format files

Clang-Format is a widely-used C++ code formatter. It provides an option to define code style options in YAML-formatted files — named .clang-format or _clang-format — and these files often become a part of your project where you keep all code style rules.

Use this checkbox to make ReSharper respect code formatting styles defined in Clang-Format configuration files. For more information, refer to Using Clang-Format.

Write current style to .clang-format

Click this button to export code styles from ReSharper settings to a .clang-format file.

Read code style from StyleCop files

When StyleCop integration is enabled, settings from StyleCop configuration files (RuleSet and Settings.StyleCop) will override ReSharper code formatting and code syntax styles, and enable corresponding code inspections.

If you have the StyleCop.Analyzers NuGet package installed in your project, ReSharper will also read and apply the default values of the StyleCop Analyzers styles. These values will take precedence over the corresponding styles in ReSharper settings, but they will be overridden by the values from the configuration files, if any.

If you use EditorConfig and StyleCop configuration files simultaneously, the StyleCop settings will always take precedence over both EditorConfig properties and ReSharper settings.

Show status bar indicator if code style configuration file is used

If this option is enabled, ReSharper displays the ThemedIcon.ProjectPropertiesFile.Screen.(Gray).png icon in the bottom right part of the Visual Studio window if there are any code style configuration 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: 30 July 2024