Vim中有没有用来折叠HTML标签的插件?
或者有另一种方法可以设置快捷方式来折叠或展开html标签?
我想要折叠/展开html标签,就像我使用缩进折叠一样。
发布于 2012-09-12 10:55:58
我发现zfat (或者,同样的,zfit)可以很好地折叠HTML文档。za将切换(打开或关闭)现有的文件夹。zR打开当前文档中的所有折叠,zM有效地重新启用文档中标记的所有现有折叠。
如果您发现自己经常使用folds,那么可以在.vimrc.中为自己做一些方便的键绑定
发布于 2013-06-30 05:20:34
如果您缩进您的HTML,以下内容应该可以工作:
set foldmethod=indent我发现这样做的问题是有太多的折叠。为了解决这个问题,我使用zO和zc分别打开和关闭嵌套的folds。
有关详细信息,请参阅help fold-indent:
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.发布于 2016-07-09 13:51:20
用foldmethod语法折叠html,更简单。
这个答案是基于HTML syntax folding in vim的。作者是@Ingo Karcat。
vim命令行:set foldmethod=syntax
或者将设置放在~/.vim/after/ftplugin/html.vim中
setlocal foldmethod=syntax
所以,这是折叠的:,这不是在这里和
~/.vim/after/syntax/html.vim语法折叠是在除了void html元素之外的所有元素之间执行的(那些没有接近兄弟的元素,比如<br>)
语法区域start="<\z(\<(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|para|source|track|wbr>)\@+>)\%(\s*\^/\?>|\s\^>*\_^>/>)“end="”fold transparent keepend extend containedin=htmlHead,htmlH\d
https://stackoverflow.com/questions/7148270
复制相似问题