是否有一些插件可以在Vim中摺疊HTML標籤?
或者還有另一種方法來設置摺疊或展開html標籤的快捷方式?
我想摺疊/展開html標籤,就像我使用縮進摺疊一樣。如何使用Vim摺疊/展開HTML標籤
回答
我發現zfat
(或同樣地,zfit
)適用於摺疊HTML文檔。 za
將切換(打開或關閉)現有摺疊。 zR
打開當前文檔中的所有摺疊,zM
有效地重新啓用文檔中標記的所有摺疊。
如果你發現自己使用的褶皺廣泛,你可以爲自己一些方便的快捷鍵綁定在你的.vimrc.
您的答案只適用於手動方式的fold方法,並且不能用於其他方法。 – soarinblue
如果縮進你的HTML下面應該工作:
set foldmethod=indent
這樣做的問題,我發現,有太多褶皺。爲了解決這個問題,我分別使用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.
嘗試設置fdl = 3默認關閉第三級摺疊或更高; zc仍然關閉打開的摺疊。 – JRG
安裝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
http://www.google.com.hk一部開拓創新的html:
JS-beautif y和VIM倍:
添加由詹姆斯來回答。 最初我的foldmethod =語法,所以zfat不起作用。 解決方案是將foldemethod設置爲手動
:setlocal foldmethod=manual
檢查其在使用中使用foldmethod,
:setlocal foldmethod?
與使用foldmethod語法,這是更簡單的摺疊的HTML。
此答案根據HTML syntax folding in vim。作者是@Ingo Karcat。
設置要與語法的摺疊方法如下:
vim的命令行
:set foldmethod=syntax
或將設定在
~/.vim/after/ftplugin/html.vim
setlocal foldmethod=syntax
還要注意到目前爲止,默認語法腳本僅摺疊多行 標籤本身,而不是開始和結束標籤之間的文本。
So, this gets folded: <div class="foo" id="bar" > And this doesn't <div> <b>text between here</b> </div>
若要摺疊標籤之間,你需要擴展語法腳本,通過 以下,最好的地方爲
~/.vim/after/syntax/html.vim
幾乎是無效的HTML元素之間進行語法摺疊 (那些別「T有一個閉合的兄弟姐妹,像
<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
首先set foldmethod=syntax
並嘗試zfit
摺疊開始標記和zo
展開標記,它在我的vim上運行良好。
- 1. Vim摺疊使用新標記擴展
- 2. Vim摺疊 - 標記打開摺疊
- 3. Bootstrap展開全部標籤後摺疊
- 4. 展開/摺疊HTML表格
- 5. 重複Vim摺疊命令(例如zfat:摺疊標籤)
- 6. 展開和摺疊圖標
- 7. 摺疊標籤 - 跳到打開標籤
- 8. 如何使可展開/可摺疊ImageView
- 9. 使iframe展開/摺疊
- 10. JQuery用Font Awesome圖標展開摺疊
- 11. vim摺疊 - 如何複製展開的線條
- 12. 如何摺疊/展開vim中的treeview(內置netrw)?
- 13. 標籤摺疊
- 14. 展開/摺疊Div
- 15. 展開/摺疊 - Javascript
- 16. 摺疊/展開Groupboxes
- 17. 展開/摺疊divs
- 18. jquery展開/摺疊?
- 19. 展開/摺疊jQuery
- 20. 摺疊/展開optgroups
- 21. 摺疊/展開表
- 22. 如何使用vim摺疊C代碼?
- 23. 打開新標籤在Vim中撤銷代碼摺疊
- 24. 用+和 - 展開/摺疊+
- 25. 用css展開和摺疊
- 26. 在JavaScript中展開摺疊菜單HTML
- 27. 展開/摺疊HTML中的文本 - Javascript
- 28. 在html表上展開摺疊
- 29. Javascript展開/摺疊div加載展開而不是摺疊
- 30. 如何用局部視圖展開/摺疊html表格?
'set foldmethod = syntax'適用於HTML –