Category Archives: Vim

Vim colorscheme customization

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.

Testing

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:

:highlight

To see a specific value (tip: have wildmenu enabled for tab-completion support):

:highlight CursorLine

02_vim-cs-cursorline

To customized a value:

:highlight CursorLine ctermbg=255

Tips:

  • hi = highlight
  • 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: :so $VIMRUNTIME/syntax/hitest.vim

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 ~/.vim/colors.

Configuration file

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

AfterColors plug-in

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:

touch ~/.vim/after/colors/desert.vim

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:

:colorscheme desert

… or type colo for the abbreviated version.

Some Vim colorschemes I came across

terminal with text editor

Most of the time when typing I’m pretty happy just doing that. But today I thought about it a bit and my colorscheme I realized I was hoping could do more. So today I updated my Vim colorscheme for the first time in two years. I came across some very nice ones. Here are a few of them. (Click image to visit their websites.)

rdark-terminal

vcs_1_rdark-terminal

gruvbox

vimcs_2_gruvbox

jellybeans

This is the colorscheme I decided on for when I like a dark background, and I customized it a bit:

" Vim colorscheme customizations: jellybeans

highlight Normal     ctermbg=323232
highlight Normal     ctermbg=303030
highlight CursorLine ctermbg=238
highlight Visual     ctermbg=240

vcs_7_jellybean-blueberry

pencil

This colorscheme is what I’m going to use for awhile. Because I spend a lot of daytime at the terminal, this colorscheme works well for the eyes. I like it quite a bit.

05_pencil

I also made a few edits for this one:

" Vim colorscheme customizations: pencil

set background=light  " override dark as colorscheme forces

highlight CursorColumn ctermbg=255
highlight CursorLine   ctermbg=255
highlight Normal ctermbg=none
highlight IncSearch    ctermfg=197 ctermbg=none
highlight Search       ctermfg=199 ctermbg=none

Thank you to all the colorscheme designers who have helped my editing out.