我想知道如何设置vim为新的html5元素(即"画布"和"视频")着色,就像现有的"脚本","body"元素(或其他语言中的保留字,如python的"def")当前版本来自通常用于终端仿真器的MacPorts.
mic*_*ael 29
html.vim是Vim参考的语法文件,以确定哪些标签将被着色.这个位置取决于你安装的Vim.在此语法文件中,您将看到许多行,如下所示:
" new html 4.0 tags
syn keyword htmlTagName contained abbr acronym bdo button col label
syn keyword htmlTagName contained colgroup del fieldset iframe ins legend
syn keyword htmlTagName contained object optgroup q s tbody tfoot thead
Run Code Online (Sandbox Code Playgroud)
这些行定义语法关键字.在这种情况下,它们专门定义HTML标记名称.第一行告诉Vim的颜色abbr,acronym,bdo,button,col,和label标签.您可以使用以下语法告诉Vim为其他标记着色:
" new html 5 tags
syn keyword htmlTagName contained video canvas
Run Code Online (Sandbox Code Playgroud)
Vim现在将为您添加颜色video和canvas标签以及任何其他关键字.
但是,如果更新内置版,html.vim它将在下次更新Vim时被覆盖,因此最佳做法是将规则附加到这些内置版本.为此,请在文件夹after/syntax中创建文件夹路径.vim并html.vim在其中放置一个文件夹路径.
下面的@ user240515提到了这个要点中的大量HTML 5元素和参数.将其内容粘贴到新创建的内容中html.vim.
咨询:help html.vim更多信息.
Joh*_*han 22
感谢您提出这个问题,感谢您接受的答案!这是为html 5添加的新标签的完整列表,因为它们是在撰写本文时定义的:
" new html 5 tags
syn keyword htmlTagName contained article aside audio canvas command datalist
syn keyword htmlTagName contained details embed figcaption figure footer header
syn keyword htmlTagName contained hgroup keygen mark meter nav output progress
syn keyword htmlTagName contained rp rt ruby section source summary time video
Run Code Online (Sandbox Code Playgroud)
chi*_*gsy 10
我正要尝试这个:
http://github.com/othree/html5.vim
看起来很完整.
编辑:我没有看到任何有关缩进的信息.:(
编辑[12/23/2012]:我这样做:)但也许是后来添加的:https://github.com/othree/html5.vim/tree/master/indent
只需将以下文件放在〜/ .vim /语法中: