YAML tab size forced at 4 spaces? Follow
When I format a .yml file, it indents at 2 spaces; when I hit Tab, it puts 4 spaces. This is causing my file to have mixed indentation. This is driving me crazy.
When I go to Preferences > Editor > Code Style > YAML, the Tabs and Indents tab only has these settings:
- Indent: 2 (default)
- Keep indents on empty lines: unchecked by default
- Indent sequence value: checked by default
There's nothing about Tab space size... but I'd imagine it would use the Indent 2 setting.
What's going on? Is this an unfinished feature in PHPStorm?
Other languages have more detailed settings:
Please sign in to leave a comment.
When I hit tab inside a .yaml file - it is indented with 2 spaces here, not 4. Are you on 2021.3.2? Is it a pure .yaml file? Do you have an .editorconfig file in the project that could possibly interfere with IDE settings?
I get inconsistent auto-indent behavior in .yml files depending on whether I paste or hit Tab or use keyboard shortcut auto-formatting (selected or unselected text), or from which context it's coming from (like from a previous line after hitting Enter/Return).
Also, keyboard shortcut comment/uncomment block/line is inconsistent. It's frustrating especially considering other more common file types work consistently with indents and spacing. Sometimes it indents 2, sometimes 4.
I don't know what you mean by "pure .yaml file". All of the YAML files I work with have extension .yml, and follow PHPStorm's default settings (though logically inconsistent depending on context as I mentioned above).
I'm using PHPStorm 2022.1, and I let it update as it reminds me.
Some of the projects I've worked on use .editorconfig, like web/assets/vendor/select2/.editorconfig... the vendor folder here has been committed to the repo unfortunately by people before me, and I'm unclear how it was generated; I didn't add it nor have I ever needed to work with it; however I don't think it applies to my issue here, because there's nothing in it about YAML files:
(sorry that I don't see how to make that code block appear like a code block other than using the quotes button in the WYSIWYG toolbar)
Please check if disabling the Settings | Code Style | Detect and use existing file indents for editing option makes the behavior consistent.
Do you mean Preferences -> Editor -> Code Style?
Won't this affect all file types? I use .php, .js, .css, all kinds of other file types besides .yml. I don't want them negatively affected. How will unchecking that option affect the non-.yml file types?
The option affects all file types, disabling it will make PhpStorm follow the Code Style settings rather then try to guess the settings by looking at each file.