YAML formatting

Answered

Can't find a definite answer to this anywhere so I have to ask here: how do I make IntelliJ format yaml?

I've just converted over my maven pom.xml to pom.yml so I need it now and unlike the properties files, this is going to require a lot of indenting.

However I want to change the default indent from 2 spaces to 4 and when I change it in the Settings->Editor->Code Style->YAML, it has no effect.

I tried installing the Snake YAML plugin and it says in its notes that the default YAML setting for file extensions has to be changed to take over the .yml extensions - so implying that native IntelliJ should format YAML???

I saw a bug on youtrack showing that formatting for YAML was still an open issue so I'm a bit pessimistic about this.

https://youtrack.jetbrains.com/issue/RUBY-2185

OK, so it is for RUBY but I suspect if you have YAML formatting for one thing, you would re-use it everywhere.

However there is a large chance I am suffering from temporary cerebral aphasia (non-heriditary stupidity) - because I do this and get zero results:

 

- go to Settings -> Editor -> Code Style -> YAML

- change "Indent" field to 4 & apply

- open file with 2-space indents

- press ctrl-alt-L

- get small advice pop-up "No lines changed: content is already properly formatted"

 

1
5 comments

Please see https://youtrack.jetbrains.com/v2/issue/RUBY-2185 and the linked issues.

It's still work in progress.

0
Avatar
Permanently deleted user

The same issue seems to affect the SnakeYAML plugin - is that expected?

0

Yes, unless the plug-in implements its own formatting.

0

- press ctrl-alt-L has not effect on my file in PyCharm, work perfectly in java ide

 

0

Please report at https://youtrack.jetbrains.com/issues/IDEA with a sample project to reproduce. Make sure there is no .editorconfig file in a project which may override IDE formatting settings.

0

Please sign in to leave a comment.