Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim foldmethod=indent when indent is two spaces

Tags:

vim

xml

I have XML which looks like this:

<object>
  <object>
    a
  </object>
  <object>
    b
  </object>
</object>

and to edit it more easily, I would like to use folding, but when I try set foldmethod=indent it does nothing. Possible it have something to do with that my xml is indented with two spaces, not four, but I'm not sure about that.

How to turn on indenting for such file properly?

like image 787
Bunyk Avatar asked Feb 13 '23 12:02

Bunyk


1 Answers

You should bear in mind that the foldlevel is computed from the indent of the line, divided by the shiftwidth & rounded down. If you haven't set sw correctly, VIM might never create a fold where you expect it to.

Setting :set sw=2 should give you the expected results.

like image 105
Michael Foukarakis Avatar answered Feb 21 '23 07:02

Michael Foukarakis