The default Vim folding rules for YAML files were always a bit of an eye strain for me. The folding commands do not behave as one would expect them to as well. More about all this in the Explanation section below.
A fold contains the beginning of a YAML section with everything underneath it included.
If you know what I'm talking about and do not care for an explanation, feel free to skip the Explanation and install vim-yaml-folds if you would like.
Here is what it looks like YAML folding looks like with the default Vim configuration:
The most obvious issue is the format of the fold lines. Take a look at the following line:
Starting with the plus symbol (
+) followed by a bunch of dashes (
the number of lines just looks like noise. Also, shouldn't it just be folded
up into the
test_self section? Same should apply to list of
The default folding behaviour for YAML files in Vim is that the folding
level matches the indentation level of the line. What ends up happening is
that the folding level begins on the line following the start of a YAML
block. This default folding rules can lead to some unexpected behaviour. Say
you move the cursor to the
test_self: and try and fold everything under it
zc). What actually happens is that everything under
vim-yaml-folds is an attempt at cleaning all this up.