What is EditorConfig and how does JetBrains Rider extend it?
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.
As EditorConfig convention suggests, JetBrains Rider will apply formatting styles defined in files named .editorconfig in the directory of the current file and in all its parent directories until it reaches the root filepath or finds an EditorConfig file with
JetBrains Rider understands standard EditorConfig properties, most of Roslyn EditorConfig properties, and provides a set of custom EditorConfig properties, which allow for much more granular configuration of formatting rules - in fact, there are properties for each preference available in the JetBrains Rider options dialog. This means that you can maintain the entire configuration of formatting rules in EditorConfig files. Below is an example of .editorconfig settings supported by JetBrains Rider:
root = true [*] # Most of the standard EditorConfig properties are supported indent_size=2 max_line_length=100 # Most of Roslyn EditorConfig properties for Visual Studio 2017 are supported csharp_space_between_parentheses=expressions, type_casts, control_flow_statements csharp_new_line_within_query_expression_clauses=true # Greater flexibility in configuring code formatting styles with custom EditorConfig properties resharper_csharp_brace_style=next_line resharper_csharp_blank_lines_around_invocable=2
EditorConfig in your solution
By default, EditorConfig styles are enabled and they will override formatting preferences defined in JetBrains Rider options. If you want JetBrains Rider to ignore EditorConfig styles, clear the corresponding check box on thepage of JetBrains Rider settings (Ctrl+Alt+S).
When EditorConfig support is enabled and there are .editorconfig files that affect the current file, JetBrains Rider will help you understand which EditorConfig styles are applied and where these settings come from:
- On JetBrains Rider formatting options pages, you will see a yellow warning if at least one preference on a page is overridden by EditorConfig styles for the current file, each overridden preference will also be highlighted with yellow. For example:
Disabling JetBrains Rider formatter with EditorConfig
Standard EditorConfig properties support note
JetBrains Rider will apply the following standard EditorConfig properties:
indent_size property with csharp_indent_size and js_indent_size properties.
Roslyn EditorConfig properties support note
As of version 2018.1, JetBrains Rider supports Roslyn EditorConfig properties with the exception of the following ones: