Folding HTML with vim

2016-08-15 14:01

I usually fold manually when working with HTML files:

:setlocal foldmethod=manual

Then I use zfat to fold and za to toggle the fold.

at is a text object in this context. To see how this works you can use it in visual mode to see what will be affected: vat.

If you want to use syntax folding you can set:

:setlocal foldmethod=syntax

I find this a bit too much but it might suit you. To make it behave a bit better when dealing with multiline tags you could follow the advice given here.