In an earlier vim color tutorial I described how to have fine-grained control of your vi and vim color settings. In this article we'll take a much easier route, and just show how you can use existing color schemes in your vi editor sessions.
Using a vim color scheme is actually pretty simple. If you're in a vi editor session, just issue the vi
colorscheme command from last line mode, like this:
Or, if you prefer less typing, just use the
colo command, like this:
Either of these commands tell vi that you want to use the
delek colorscheme. If you want to use the
desert color scheme instead, just specify it instead of
delek, like this:
Once you've settled on a vim colorscheme that you like, you'll want to configure that as your default colorscheme in your vim configuration file, vimrc. The vimrc file is located in your home directory, and on Unix and Linux systems the vimrc file actually begins with a decimal (it's a "hidden" file), so you can edit it like this:
To use the
desert colorscheme just add these lines to your vimrc file:
colo desert syntax on
(For more information on vimrc configuration files, see my vim vimrc configuration file example.)
A common question at this point is "What color schemes are available on my system?"
You can find your installed vim colorscheme files in the
colors subdirectory of your vim installation directory. All the files end with the file extension
.vim, and begin with the name of the colorscheme. As an example, I just found all these files in the
/usr/share/vim/vim72/colors directory on my Mac OS X system:
blue.vim darkblue.vim default.vim delek.vim desert.vim elflord.vim evening.vim koehler.vim morning.vim murphy.vim pablo.vim peachpuff.vim ron.vim shine.vim slate.vim torte.vim zellner.vim
If you don't like any of these default color schemes, you can find others on the internet, or even create your own, using one of these files as an example. Or, if you'd like to tweak a few colors manually, take a look at our vi/vim color settings tutorial.
As a final note, if you're new to the concept of syntax highlighting, here's a link to our vi/vim syntax highlighting tutorial.