Setting a vim Color Scheme

I was recently lecturing on API and API Design with Python, and was in a room where the projector was nearing it’s last days. With significantly less lumens, it was difficult to see the blue comments on black background. Perhaps your reasons are different, but if you’re looking for instructions for setting a vim color scheme, read on.

From within vim, issue the following command to change to the ‘morning’ theme.

:colorscheme morning

Now from within vim, issue the following command to change to the ‘industry’ theme.

:colorscheme industry

If you’re lazy, you can shorthand the colorscheme command as follows.

:colo blue

To cycle through available choices, type the :colorscheme command, ‘space’ then the ‘tab’ key. Continue to tap ‘tab’ to cycle through choices.

:colorscheme [tab]

Color Schemes Available in vim

Available vim color schemes include the following:

  • blue

  • darkblue

  • default

  • delek

  • desert

  • elflord

  • evening

  • industry

  • koehler

  • morning

  • murphy

  • pablo

  • peachpuff

  • ron

  • shine

  • slate

  • torte

  • zellner

All of these colors have corresponding files ending in .vim, for example, there is a ‘zellner.vim’ file on your system that describes the zellner color profile.

On my Ubuntu machine, the location of these profiles is /usr/share/vim/vim80/colors/ however on any Linux system you should be able to locate the location of your profiles by running a command like the following:

sudo find / -name zellner.vim

Try displaying one of these *.vim profile files on the screen. Neat to see it once.

Persistent color settings with ~/.vimrc

Setting a color scheme within a vim session is easy, but if you exit that session, your color preference will be lost. If you want your color choices to persist, place the settings within ~/.vimrc file. To edit this file, issue the following command.

vim ~/.vimrc

The “~/” means, “current user’s home directory”. The “.vimrc” is the name of the file. In Linux, any file preceded by a dot is hidden.

An example ~/.vimrc file that would allow the elflord setting to persist would look like the following.

colo elflord
syntax on
" Make comments in ~/.vimrc with preceding double-quotes

Helpful Links

Previous
Previous

Python versions? “Python2” vs “Python3”?

Next
Next

Python and APIs – NASA’s Open APIs