The gvim program alone does not have syntax highlighting enabled by default. Syntax highlighting is only enabled by explicitly enabling it with a command such as :syntax on
. So the only way to have syntax enabled is to enable it yourself at the Vim command line or to have such a command in a configuration file that's read on startup.
Vim is typically installed on Windows with a standard set of configuration commands in C:\Program Files\Vim\_vimrc
. That standard set includes syntax on
. Without any other configuration files, gvim will read that file on startup and you will have syntax highlighting.
In :help _vimrc
it says, "Four places are searched for initializations. The first that exists is used, the others are ignored." The list of user vimrc files includes $HOME/_vimrc
followed by $VIM/_vimrc
. On your system, $VIM is C:\Program Files\Vim
.
So, when you use a C:\Documents and Settings\myUsername\_vimrc
file, gvim reads that file and skips C:\Program Files\Vim\_vimrc
. If your _vimrc does not contain syntax on
you will not get syntax highlighting.
If your are going to use your own _vimrc, then make sure you copy into it from C:\Program Files\Vim\_vimrc
any of those configuration commands you need, including syntax on
.
Thank you Gary! This is exactly what I needed to know. I'm rather glad to know that the answer is in the fine manual, I'm going to go through it later today. Thanks! – dotancohen – 2012-04-17T16:58:12.380
Thank you for that. How odd that
gvim
7.3 on Linux seems to default this toon
(I can't findsyntax on
in any of the.vimrc
or.gvimrc
files on my Linux system), butgvim
7.3 on Windows doesn't. – T.J. Crowder – 2012-07-20T13:54:36.010@T.J.Crowder: The set of files discussed in the answer are referred to as personal initialization files. Before loading one of those, Vim searches for and loads a system initialization file. (See
:help startup
.) A standard Vim installation on Windows has a personal initialization file at $VIM/_vimrc but no system initialization file, so your $HOME/_vimrc is loaded instead of $VIM/_vimrc. A standard Vim installation on a Linux distribution has a system initialization file usually at $VIM/vimrc which is always loaded before and in addition to the personal initialization file. – garyjohn – 2012-07-20T15:04:09.380@T.J.Crowder: So you will find a
syntax on
command in the system initialization file on your Linux system, probably in /usr/share/vim/vimrc or /etc/vimrc. The location is given in the output of the:version
command. – garyjohn – 2012-07-20T15:06:26.493@garyjohn: Right, I looked in those as well before posting the above. I can't find one in any of them. I've looked in any
.vimrc
,.gvimrc
, andgvimrc
file I could find under both$VIM
and$HOME
. – T.J. Crowder – 2012-07-20T15:07:11.577@garyjohn: The one I missed out was
$VIM/vimrc
(no.
). That's where it was hiding. I looked for$VIM/.vimrc
instead (doh!). We should clean these comments up, they won't help anyone who doesn't do the same dumb thing. :-) – T.J. Crowder – 2012-07-20T15:12:22.557