用于html的Vim折叠
所以这可能已经被问过好几次了,但还没有一个明确的答案。在vim中折叠html块 以下面的标记为例用于html的Vim折叠,html,vim,folding,Html,Vim,Folding,所以这可能已经被问过好几次了,但还没有一个明确的答案。在vim中折叠html块 以下面的标记为例 <html> <body> <section> <ul> <li></li> <li></li> </ul> </section> <section> <ul>
<html>
<body>
<section>
<ul>
<li></li>
<li></li>
</ul>
</section>
<section>
<ul>
<li></li>
<li></li>
</ul>
</section>
</body>
</html>
如果这能奏效或者有更好的选择,你有什么想法吗
编辑
我现在拥有的
autocmd FileType html setlocal foldmethod=indent
autocmd FileType html setlocal fdl=3
如果我在任何一个截面元素上切换一个折叠,它将把所有的截面元素折叠成一个折叠
<html>
<body>
<section>…
</body>
</html>
…
相反,它应该只为每个单独的节或div元素切换一个折叠
<html>
<body>
<section>…
<section>…
</body>
</html>
…
…
我有点不确定你想要实现什么,但是如果你
autocmd FileType html setlocal foldmethod=indent
autocmd FileType html setlocal fdl=3
您应该获得以下信息:
<html>
<body>
<section>
<ul>
+---- 2 lines: <li></li>-------
</ul>
</section>
<section>
<ul>
+---- 2 lines: <li></li>-------
</ul>
</section>
</body>
</html>
以获得上述结果。要切换标签的折叠,请使用。对于其他选项,请阅读(它很好,内容广泛)。另一个不错的选择是(尝试设置foldcolumn=4)。你能添加一个“实际”和一个“期望”的样本吗?你能解释一下“实际”和“期望”的含义吗?实际是你目前拥有的,期望是你想要的。
<html>
<body>
<section>
<ul>
+---- 2 lines: <li></li>-------
</ul>
</section>
<section>
<ul>
+---- 2 lines: <li></li>-------
</ul>
</section>
</body>
</html>
set shiftwidth=2