How to set and use a vim color scheme

In an earlier vim color configuration tutorial I described how to have fine-grained control of your vim color settings. In this article I’ll take an easier route, and just show how you can use existing color schemes in your vim editor sessions.

Note: In an previous version of this document I referred to both vim and the vi editor, and someone correctly pointed out that the two are not the same, especially in this case.

Back to top

Using a vim color scheme

Using a vim color scheme is actually pretty simple. If you’re in a vim editor session, just issue the vim colorscheme command from last line mode, like this:

:colorscheme delek

Or, if you prefer less typing, just use the colo command, like this:

:colo delek

Either of these commands tell vim 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:

:colo desert

Note: If those color schemes don’t seem to make any change to your vim session, try some of the other color schemes listed below, such as darkblue, evening, shine, etc.

Back to top

Specifying a colorscheme in your vimrc file

Once you’ve settled on a vim colorscheme that you like, you’ll want to configure that as the default colorscheme in your vim configuration file, vimrc. The vimrc file is located in your home directory, so on Mac, Unix, and Linux systems the vimrc file actually begins with a decimal (it’s a “hidden” file), so you can edit it like this:

vi ~/.vimrc

I haven’t used Windows in a long time, but I think the filename is just vimrc on Windows’ systems.

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.)

Back to top

What vim color schemes are installed?

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:

Back to top

Manual vi/vim color control

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 my vim editor color settings tutorial.

As a final note, if you’re new to the concept of syntax highlighting, here’s a link to my vim syntax highlighting tutorial.

Back to top

Just to make it clear, vi is NOT vim, and they do not work the same way. So no *.vim colorscheme or :colorscheme for vi, those are vim-only features.

Yes, thank you, I should be more clear on this. On some systems vi is a symbolic link to vim, on others vi and vim are different binaries, and on older systems vim isn't even available.

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.