There are two ways to make "syntax on" in Vim: syntax enable
and syntax on
. What preferred to put into vimrc
? What the difference between them? I have read :h :syn-qstart
and don't feel the difference.
The answer is more or less given at :h syntax_cmd
. Basically, what Vim does is
let g:syntax_cmd = enable ? "enable" : "on"
source $VIMRUNTIME/syntax/syntax.vim
unlet g:syntax_cmd
So the difference (if any) is how runtime files (actually, $VIMRUNTIME/syntax/syncolor.vim
which gets sourced through synload.vim
which, in turn, is sourced through syntax.vim
) treat the value of syntax_cmd
variable.
"Enabled"-version uses :hi def
to set the colors for standard syntax groups, while "on"-version just :hi
. But you need to do something rather tricky to encounter any difference.
$ vim -u NONE
:colo blue
:scr 1
:unlet g:colors_name
:syn enable
: "text is colored with "blue" colorscheme
:syn on
: "background is still "blue" but many colors now come from "default"
So usually syntax enable
is slightly preferred, but you may just ignore this. At least, I'm not able to imagine a truly realistic situation where it matters.