Switch color schemes

You can easily change your color scheme, but it can be hard to compare several schemes to decide what's best for you. It may help to view a one-page summary of many color schemes.
Alternatively, the script presented below allows you to quickly change colors by pressing a key. If you like variety, you can start Vim with a different scheme depending upon the time of day.

Contents

Maverick Woo has created a one-page summary showing sample C code in many different color schemes. Other pages at the same site show similar information for html, Java, LaTeX and Perl.

Some of the color schemes are provided with Vim. For example, the following command should show the elflord scheme:

:colorscheme elflord

Many samples show color schemes available at Vim scripts – at that page, click "Advanced search" in the left sidebar, then, under "on the Vim website only", select "color scheme" for the "type", and click Search. The results include the Color Sampler Pack which is a zip of the 100 highest rated color schemes (previewed here).

Note that if you are using Vim over SSH or in certain color-limited terminals you may need to tell Vim to use 256 color mode in order to have the color schemes display with greater accuracy by using the command :set t_Co=256 .

The next/previous/random color scheme selection uses a list of scheme names maintained by the script. The list can be controlled with these commands (the default is all):

:SetColors all

To use all installed color schemes ($VIMRUNTIME/colors/*.vim).

:SetColors my

To use names built into the script (define these names by editing the script to change the variables c1, c2 and c3).

:SetColors blue slate ron

To use the schemes specified (scheme names, separated with a space, for example, blue slate ron).

:SetColors

To display the current list of scheme names.

After using :SetColors to list the scheme names (and while the list is still displayed), you could type :colors d then press Tab to expand 'd' to a color scheme name starting with 'd'. Then press Enter to invoke the color scheme (:colors is an abbreviation for :colorscheme).

Enter :SetColors now to set the current color scheme based on the time of day. Change the colors used by editing the nowcolors variable in the script, for example:

You may want to impress your colleagues by having Vim change the color scheme periodically. The following might be your first attempt:

:autocmd CursorHold * call NextColor(1)

However, this fails because there is no timer event in Vim. The CursorHold event will fire only once when the user has been idle for the time specified with the 'updatetime' option (so if you stop typing, the color scheme will change once only).

If you want the color scheme to change every 10 seconds, execute the following command (press Ctrl-C to finish).

It's kind of weird that s:mycolors is set initially to something different than "my" or "all". You can't get that list back after using the script.

Wouldn't it be cool if you could edit the "my" list on the fly with some commands? Wouldn't it be even cooler if the "my" list was taken from a global variable, which could even be stored in the .viminfo file by including ! in the 'viminfo' option?