'foldmethod' is a window-local option; setting it from your
~/.vimrc doesn't necessarily have the right effect.
Because syntax folding is bound to the
html filetype, these settings belong to
This depends on having
filetype plugin on in your
~/.vimrc, which you probably have. You can also configure other related options there, e.g.
Also note that so far (as of Vim 7.4.1830), the default HTML syntax script only folds a multi-line tag itself, not the text between the opening and closing tag.
So, this gets folded:
But this doesn't:
<b>stuff in between</b>
To get this, you need to extend the syntax script, e.g. via the following, best placed into
Folding is performed between all but void html elements (those which don't have a closing sibling, like
<br>). Contributed by @zanona; thanks!
syntax region htmlFold start="<\z(\<\(area\|base\|br\|col\|command\|embed\|hr\|img\|input\|keygen\|link\|meta\|para\|source\|track\|wbr\>\)\@![a-z-]\+\>\)\%(\_s*\_[^/]\?>\|\_s\_[^>]*\_[^>/]>\)" end="</\z1\_s*>" fold transparent keepend extend containedin=htmlHead,htmlH\d
Folding is performed between certain explicitly named structural (e.g.
<head>), paragraph-level (e.g.
<li>) and ancillary (e.g.
<script>) HTML tags.
syntax region htmlFold start="<\z(p\|h\d\|i\?frame\|table\|colgroup\|thead\|tfoot\|tbody\|t[dhr]\|pre\|[diou]l\|li\|span\|div\|head\|script\|style\|blockquote\|form\)\%(\_s*\_[^/]\?>\|\_s\_[^>]*\_[^>/]>\)" end="</\z1\_s*>" fold transparent keepend extend containedin=htmlHead,htmlH\d