天天看點

vim折疊html代碼,如何使用Vim折疊/展開HTML标簽

If you indent your HTML the following should work:

set foldmethod=indent

The problem with this, I find, is there are too many folds. To get around this I use zO and zc to open and close nested folds, respectively.

See help fold-indent for more information:

The folds are automatically defined by the indent of the lines.

The foldlevel is computed from the indent of the line, divided by the

'shiftwidth' (rounded down). A sequence of lines with the same or higher fold

level form a fold, with the lines with a higher level forming a nested fold.

The nesting of folds is limited with 'foldnestmax'.

Some lines are ignored and get the fold level of the line above or below it,

whichever is lower. These are empty or white lines and lines starting

with a character in 'foldignore'. White space is skipped before checking for

characters in 'foldignore'. For C use "#" to ignore preprocessor lines.

When you want to ignore lines in another way, use the 'expr' method. The

indent() function can be used in 'foldexpr' to get the indent of a line.