In my .vimrc file I use:
syntax on
Today, I was perusing through some .vimrc files from other developers and i\'ve notice a few using:
For syntax on
vs syntax enable
, the help files claim:
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
The behavior I see in Vim does not appear to match the above help statement.
After testing locally with some empty .vimrc
s and experimenting with on
, enable
, and placement of highlight commands, I can't figure out what Vim is actually doing (I tested with highlight ColorColumn guibg=#331111
and set colorcolumn=80
). Highlighting is sometimes overwritten and sometimes not.
I no longer trust Vim, so I only let syntax get set once, ever. Here's what I have in my .vimrc
:
if !exists("g:syntax_on")
syntax enable
endif
I use enable
because of the above claim that it won't overwrite your settings, however it doesn't seem to make any difference when starting Vim.
You can see that h g:syntax_on
shows that on
and enable
source the same file:
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
If you're curious, g:syntax_on
gets set in $VIMRUNTIME/syntax/synload.vim
Also running Vim with no plugins/settings vim -u NONE
does NOT load any of the syntax files.