我有.zsh-theme文件(来自oh-my-zsh),但它们没有突出显示语法.我能够轻松完成这项工作
autocmd BufEnter *.zsh-theme set filetype=sh
Run Code Online (Sandbox Code Playgroud)
但是,在我这样做之前,我尝试为特定文件添加vim元注释
#vim: set filetype=sh
Run Code Online (Sandbox Code Playgroud)
添加#显然使vim将文件检测为conf文件,但似乎忽略了该命令(即,尽管有注释,它仍未被检测为sh文件).有什么理由可能会发生这种情况吗?
FDi*_*off 10
摆脱单词集(并在评论符号后面添加一个空格)
# vim: filetype=sh
Run Code Online (Sandbox Code Playgroud)
这符合第一种形式的模型
There are two forms of modelines. The first form:
[text]{white}{vi:|vim:|ex:}[white]{options}
[text] any text or empty
{white} at least one blank character (<Space> or <Tab>)
{vi:|vim:|ex:} the string "vi:", "vim:" or "ex:"
[white] optional white space
{options} a list of option settings, separated with white space
or ':', where each part between ':' is the argument
for a ":set" command (can be empty)
Run Code Online (Sandbox Code Playgroud)
此类型的模式行的语法是:
[text]{white}{vi:|vim:|ex:}[white]se[t] {options}:[text]
Run Code Online (Sandbox Code Playgroud)
也就是说,尝试在之前添加空格vim:和尾随冒号:
# vim: set filetype=sh:
Run Code Online (Sandbox Code Playgroud)
你可以找到关于模特儿的一切