Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditorConfig section inheritance

Tags:

editorconfig

Lets say I have the following EditorCofig file:

[*]
indent_style = space

[.cs]
indent_size = 4

Does this definition mean indent style spaces for C# files, or do I need to explicitly specify indent_style = space in [.cs] section as well?

like image 927
Alex I Avatar asked Mar 18 '26 17:03

Alex I


1 Answers

Your section header contains a typo and should be [*.cs] to match files with the .cs extension.

To answer the question, however, you do not need to specify rules "again" for each section. It's expected that a particular file can match multiple sections in potentially multiple .editorconfig files. Editors conforming to the spec must merge the sections as follows:

Files are read top to bottom and the most recent rules found take precedence. If multiple EditorConfig files have matching sections, the rules from the closer EditorConfig file are read last, so pairs in closer files take precedence.

"Precedence" applies when the same rule appears in multiple sections. You would use indent_style = unset if you explicitly want to clear the rule from any previously matched sections.

like image 172
Kyle McClellan Avatar answered Mar 22 '26 06:03

Kyle McClellan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!