I know how to turn syntax highlighting on and off in vim by running this in the editor:
:syntax on/off
But I want syntax highlighting to be enabled by default, so I don't have to turn it on every time I run vim.
How do I do this?
Edit your $HOME/.vimrc
(Unix/Linux/OSX) or $HOME/_vimrc
(Windows) to include the following line:
syntax on
EDIT
If your syntax highlighting doesn't work when you start Vim, you probably don't have a
$HOME/.vimrc
or $HOME/_vimrc
(known collectively as vimrc
from now on). In that case, you have two options:
vimrc
.vimrc_example.vim
as your vimrc
(recommended, thanks @oyenamit). You can find vimrc_example.vim
in the runtime directory.The location of the runtime directory varies between operating systems:
/usr/share/vim/vim73
.\Program Files\Vim\vim73
.In my $HOME/.vimrc
I load a color scheme (solarized) and found that I need to place syntax on
after I load the plugin. If it's before loading the plugin it doesn't work.
" this turns syntax highlighting on by default
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'lifepillar/vim-solarized8'
syntax on
" this does not turn syntax highlighting on by default
syntax on
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'lifepillar/vim-solarized8'