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 and
Control-F8 to switch to a random 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.
Switch to a random color scheme. Because Vim doesn’t actually expose random numbers the microseconds of the current time are used to improvise a source of randomness. It’s nothing like real randomness but convincing enough for this plug-in :-).
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']
This option is a string specifying the Vim command used to switch between color schemes. It defaults to the :colorscheme command. You can set this option to integrate the vim-colorscheme-switcher plug-in with other plug-ins like colorsupport.vim and guicolorscheme.vim.
The vim-colorscheme-manager plug-in is an add-on for vim-colorscheme-switcher that adds features like more convenient blacklist management and automatic loading of the last used color scheme when Vim starts up or a session is loaded.
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 firstname.lastname@example.org. 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. © 2014 Peter Odding <email@example.com>.
Last updated Wed Jun 25 21:09:17 UTC 2014.