Jam*_*Lai 78
我发现zfat
(或者同样zfit
)适用于使用HTML文档进行折叠.za
将切换(打开或关闭)现有折叠.zR
打开当前文档中的所有折叠,zM
有效地重新启用文档中标记的所有现有折叠.
如果你发现自己广泛使用折叠,你可以为自己做一些方便的键绑定 .vimrc.
小智 19
如果您缩进HTML,则以下内容应该有效:
set foldmethod=indent
Run Code Online (Sandbox Code Playgroud)
我发现,这个问题是有太多的折叠.为了解决这个问题,我分别使用zO
和zc
打开和关闭嵌套折叠.
有关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.
Run Code Online (Sandbox Code Playgroud)
安装js-beautify命令(JavaScript版)
npm -g install js-beautify
wget --no-check-certificate https://www.google.com.hk/ -O google.index.html
js-beautify -f google.index.html -o google.index.bt.html
Run Code Online (Sandbox Code Playgroud)
http://www.google.com.hk原始html:
js-beautify 和 vim 折叠:
使用foldmethod语法折叠html,这比较简单。
该答案基于vim中的HTML语法折叠。作者是@Ingo Karcat。
使用以下命令将fold方法设置为语法:
vim命令行 :set foldmethod=syntax
或将设置放入 ~/.vim/after/ftplugin/html.vim
setlocal foldmethod=syntax
Run Code Online (Sandbox Code Playgroud)到目前为止,还请注意,默认语法脚本仅折叠多行标签本身,而不折叠开始和结束标签之间的文本。
So, this gets folded:
<div
class="foo"
id="bar"
>
And this doesn't
<div>
<b>text between here</b>
</div>
Run Code Online (Sandbox Code Playgroud)要在标签之间折叠,您需要通过以下最佳位置扩展语法脚本: ~/.vim/after/syntax/html.vim
语法折叠是在所有无效的html元素之间进行的(这些元素没有封闭的同级,例如<br>
)
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
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
21874 次 |
最近记录: |