The colorscheme switcher plug-in for the Vim text editor makes it easy to quickly switch between colorschemes. It defines commands and mappings to switch to the next and previous color schemes.
Please note that the vim-colorscheme-switcher plug-in requires my vim-misc plug-in which is separately distributed.
Unzip the most recent ZIP archives of the vim-colorscheme-switcher and vim-misc plug-ins inside your Vim profile directory (usually this is
~/.vim on UNIX and
%USERPROFILE%\vimfiles on Windows), restart Vim and execute the command
:helptags ~/.vim/doc (use
:helptags ~\vimfiles\doc instead on Windows). Now try it out: Execute
:NextColorScheme to switch to the next color scheme.
If you didn’t change the plug-in’s configuration you can now use the
Shift-F8 keys to switch to the next/previous color scheme.
If you prefer you can also use Pathogen, Vundle or a similar tool to install & update the vim-colorscheme-switcher and vim-misc plug-ins using a local clone of the git repository.
Switch to the next color scheme. After the last color scheme the cycle repeats from the first color scheme.
Switch to the previous color scheme. After the first color scheme the cycle repeats from the last color scheme.
The colorscheme switcher plug-in should work out of the box, but you can change the configuration defaults if you want to change how the plug-in works.
By default the plug-in maps the following keys in insert and normal mode:
F8switches to the next color scheme
Shift-F8switches to the previous color scheme
To disable these mappings (e.g. because you’re already using them for a different purpose) you can set the option
g:colorscheme_switcher_define_mappings to 0 (false) in your vimrc script.
If you set this variable to 1 (true) and cycle to the next/previous color scheme, the plug-in will skip color schemes with a different ‘background’. By default this is set to 0 (false).
This is useful when you want to see only light or dark color schemes, for example because the sun is shining (you’ll want a light background) or because it’s late at night (then you’ll likely prefer a dark background).
A list with names of color schemes to be ignored by the plug-in. By default the list is empty. Here’s an example of how you can set this:
:let g:colorscheme_switcher_exclude = ['default', 'test']
The way Vim color schemes are written isn’t really compatible with the idea of quickly switching between lots of color schemes. In my opinion this is an ugly implementation detail of how Vim works internally, in other words I think it’s a bug that should be fixed… Here are some references that explain the problem in some detail:
Since this behavior hinders cycling through color schemes, the colorscheme switcher plug-in includes a workaround that should hide the problem:
Probably this solution is still not perfect, but it’s a lot better than the behavior out of the box: Before I implemented the steps above, when I would cycle through my color schemes, Vim would eventually end up with black text on a white background and nothing else! With the steps above, I can cycle as many times as I want and all of the color schemes I’ve checked so far look fine.
If you have questions, bug reports, suggestions, etc. the author can be contacted at email@example.com. The latest version is available at http://peterodding.com/code/vim/colorscheme-switcher/ and http://github.com/xolox/vim-colorscheme-switcher. If you like this plug-in please vote for it on Vim Online.
This software is licensed under the MIT license.
© 2013 Peter Odding <firstname.lastname@example.org>.
Last updated Mon Aug 19 17:05:35 UTC 2013.