我有.zsh-theme
文件(来自oh-my-zsh
),但它们没有突出显示语法。我能够很容易地完成这项工作
autocmd BufEnter *.zsh-theme set filetype=sh
但是,在我这样做之前,我尝试为特定文件添加 vim 元注释
#vim: set filetype=sh
添加#
显然使vim将文件检测为conf
文件,但似乎忽略了该命令(即,尽管有注释,但未将其检测为sh
文件)。有什么原因会发生这种情况吗?
去掉词集(并在注释符号后加一个空格)
# vim: filetype=sh
这符合第一种形式的模型
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)
这种模式行的语法是:
[text]{white}{vi:|vim:|ex:}[white]se[t] {options}:[text]
也就是说,尝试在 之前添加一个空格vim:
和一个尾随冒号:
# vim: set filetype=sh:
你可以在