Any installed Vim colorscheme has the ability to be customized. They can be tested temporarily or saved to a configuration file that will leave the original colorscheme file intact.
To customize a colorscheme value, Vim has on-the-fly colorscheme alteration support to be able to test them. To get an overview of what all the values look like:
To see a specific value (tip: have wildmenu enabled for tab-completion support):
To customized a value:
:highlight CursorLine ctermbg=255
- If working from the terminal, it is useful to know what colors are available. A number of scripts can be found; I created one called termcolors.
- A test can highlight the current syntax groups:
Save to file
Customized colorscheme values can be saved in the Vim configuration file or in the
after directory with a plug-in.
It may be a good idea to begin customizing a colorscheme by reading the colorscheme author’s notes. Authors will sometimes explain their design philosophy in the colorscheme file. These files are located system-wide in
/usr/share/vim/vimfiles/colors/ or locally in
A good number of users may prefer using the AfterColors plug-in as it simplifies the process and helps keep the configuration file neat. I prefer using the configuration file because of a glitch I encountered once.
Because it is possible that I may use multiple colorschemes, I’ve put detection of the colorscheme in my configuration so customizations apply per colorscheme. Values entered into the configuration match that done while testing:
if g:colors_name == "desert" highlight IncSearch ctermfg=197 ctermbg=none highlight Search... endif
Vim uses the system directory
$VIMRUNTIME/after/ and the local directory
$HOME/after/ to supplement or overrule to the default settings. For editing colorschemes there will need to be a sub-directory called
colors. To install it locally:
mkdir -p $HOME/.vim/after/colors
For neither, however, does Vim yet support colorscheme customizations and a plug-in will need to be installed: AfterColors. I would recommend using a plug-in manager like Vundle or Pathogen to install it.
Customization values are put in a file that matches the colorscheme’s file name:
The values placed in the files are the same as done while testing:
" Vim colorscheme customizations: desert highlight IncSearch ctermfg=197 ctermbg=none highlight Search ctermfg=126 ctermbg=none highlight CursorLine ctermbg=255 highlight Visual ctermbg=45
Save the file and reload the colorscheme to see the edits:
… or type
colo for the abbreviated version.