Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JetBrains WebStorm ignores Indentation Settings

Tags:

webstorm

In Settings > Code Style > JavaScript I've set Tab size and Indent to 4. Why is WebStorm still ignoring these settings, as you can see in the preview window:

What settings could override these?

like image 301
Julian Rubisch Avatar asked Jan 07 '23 13:01

Julian Rubisch


1 Answers

If you have EditorConfig plugin enabled (which should be by default) and have .editorconfig files in your project (or maybe even above the project root) then settings from there will override your Code Style (which is expected as this is the whole point of such plugin).


Why such behaviour? What can be done?

  1. Please check what .editorconfig files are for -- they meant to be editor-independent. It meant to override your internal settings to provide consistency across different IDEs/editors used without the need to configure your IDE/editor just for this project/folder
  2. You are editing Code Style settings and not actual EditorConfig settings
  3. With .editorconfig you can do things that are not currently possible with Code Style (e.g. different right margins / trailing white space handling per different file types, even if they are not supported by Code Style)
  4. Code Style is applied to the whole project (all files) while .editorconfig can be configured differently for each sub-folder and even have exclusions.
  5. IDE should be showing you the notice (using light GUI theme it would be green bar on top of the editor window) where it would tell that "Settings may be overridden by EditorChonfig." -- I'm just not sure if it's available in WebStorm v11, or is it since v12 only.
  6. If you go one level up in your settings (just Code Style and not Code Style > JavaScript as on your screenshot) you will see mention of this moment as well
  7. You may file Feature Request ticket for such "update .editorconfig file while editing Code Style" idea at JetBrains' Issue Tracker.

Example .editorconfig file:

# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
like image 176
LazyOne Avatar answered Jan 19 '23 01:01

LazyOne