在我的.vimrc文件中,我使用:
syntax on
Run Code Online (Sandbox Code Playgroud)
今天,我正在浏览其他开发人员的一些.vimrc文件,我注意到一些使用:
syntax enabled
Run Code Online (Sandbox Code Playgroud)
有区别吗?这些都只是使用不同的locution来实现相同的目标吗?
And*_*Ray 36
对于syntax onvs syntax enable,帮助文件声称:
The ":syntax enable" command will keep your current color settings. This
allows using ":highlight" commands to set your preferred colors before or
after using this command. If you want Vim to overrule your settings with the
defaults, use: >
:syntax on
Run Code Online (Sandbox Code Playgroud)
我在Vim中看到的行为似乎与上述帮助声明不匹配.
一些空的本地测试后.vimrcS和与实验on,enable以及增亮命令的位置,我想不出什么Vim实际正在进行(我测试highlight ColorColumn guibg=#331111和set colorcolumn=80).突出显示有时会被覆盖,有时不会被覆盖.
我不再相信Vim,所以我只让语法设置一次,永远.这就是我的意思.vimrc:
if !exists("g:syntax_on")
syntax enable
endif
Run Code Online (Sandbox Code Playgroud)
我使用enable是因为上述声明它不会覆盖你的设置,但是在启动Vim时似乎没有任何区别.
您可以看到h g:syntax_on显示on和enable源同一文件:
Details:
The ":syntax" commands are implemented by sourcing a file. To see exactly how
this works, look in the file:
command file ~
:syntax enable $VIMRUNTIME/syntax/syntax.vim
:syntax on $VIMRUNTIME/syntax/syntax.vim
Run Code Online (Sandbox Code Playgroud)
如果你很好奇,请g:syntax_on加入$VIMRUNTIME/syntax/synload.vim
在没有插件/设置的vim -u NONE情况下运行Vim 也不会加载任何语法文件.