How to change Vim syntax highlighting colors?

Unbuntu has auto-configured Vim to use syntax highlighting for text (mostly, programs and configuration files of course) editing, the problem however, is that some of the colors appear to be darker than wanted on SSH console and it’s a little hard to recognize comfortably.

So how can we change the default colors of the syntax highlighting?

  1. Locate Vim configuration file which is located at /etc/vim/vimrc, add a line after ‘syntax on’: colorscheme desert
  2. Now that we are prescribing Vim to use the syntax color scheme desert, we will want to find the scheme file to change the colors that we don’t feel comfortable with. The desert color scheme file is located at: /usr/share/vim/vimcurrent/colors/desert.vim
  3. Proceed to open it with vi and replace the color values with new ones. For example, the default comment color may be a little too dark on a black screen, let’s make it lighter by changing
    hi Comment      ctermfg=darkcyan

    to

    hi Comment      ctermfg=blue
  4. Reload the vimrc configuration file by performing ‘source /etc/vim/vimrc‘ at shell.
Scroll to Top