YAML-PP-p5 icon indicating copy to clipboard operation
YAML-PP-p5 copied to clipboard

Option to indent lists relative to mapping keys

Open bpj opened this issue 4 years ago • 1 comments

Currently lists as values of mapping keys are not indented relative to mapping keys, so that e.g.

{ foo => ['bar', 'baz'] }

becomes

foo:
- bar
- baz

rather than

foo:
  - bar
  - baz

I understand that this is done so that the output shall contain as little whitespace as possible but it is a problem when using indentation as fold method in Vim because such lists will also not stay folded when the level the key is on is unfolded.

The best solution would probably be an option to indent lists relative to mapping keys, since this is a matter of taste.

bpj avatar Mar 21 '21 14:03 bpj

This is on my todo list, but not with a very high priority, because there are so much more important other issues.

I want to implement that in YAML::Tidy, so depending on your use case you could postprocess the YAML to get your preferred formatting. But haven't got the time yet.

perlpunk avatar Apr 07 '21 16:04 perlpunk