How To Set, Configure and Use Vim Color Scheme – POFTUT

How To Set, Configure and Use Vim Color Scheme


Vim is very popular ans useful text editor based command line and GUI. I prefer vim because of its featured over nano etc. Vim have color scheme and highlighting features where different syntax for programming languages can be printed in a pretty and understandable form. In this tutorial we will look how to change color schemes. Reading following tutorials will be beneficial.

Linux Vi and Vim Command Line Text Editor Tutorial

Vim Copy, Cut and Paste Commands and Operations

List Vim Color Schemes

Before selecting a color scheme we need to list vim provided color schemes.  Vim color schemes are stored in vim directory named /usr/share/vim/vim80/colors/ but vim80 can be different according to vim version. Color schemes have .vim extension. We can use ls -l command in order to print available color schemes.

$ ls -l /usr/share/vim/vim*/colors/

List Vim Color Schemes with colorscheme Command

We have an other option where we can list color schemes. We can use colorscheme command and then press space and tab. This will list avaibilible color schemes. Currently selected color scheme will be colored as yellow like below.

:colorscheme

then SPACE and TAB

List Vim Color Schemes with colorscheme Command
List Vim Color Schemes with colorscheme Command

Set Color Scheme with colorscheme Command

Now we know what color schemes are available. We will select color scheme with colorscheme command. Actually we were very close to select color scheme in previous step. We will just provide the color scheme name to the  colorscheme command. In this example we will select desert.

: colorscheme desert

and the Python script syntax will be highlighted like below.

Set Color Scheme with colorscheme Command
Set Color Scheme with colorscheme Command

Set Color Scheme with colo Command

Vim provides shortcut usage for commands. But provided part should be uniquely identifier. This means we can use colo which is unique and address colorscheme command. We will set color scheme delek in this example.

: colo delek
Set Color Scheme with colo Command
Set Color Scheme with colo Command

Make Color scheme Persistent Specifying  vimrc

Changes are not saved between vim sessions. So color scheme changes we have made will be lost in next sessions. Doing this change again and again in ever is not practical. We can save this configuration to the  vimrc configuration file and made it persistent. vimrc is located at /etc or users home directory.

echo ":colorscheme delek" >> ~/.vimrc
Make Color scheme Persistent Specifying  vimrc
Make Color scheme Persistent Specifying  vimrc

3rd Pary Color Schemes

As vim is modular tool there are alot of different color schemes provided by 3rd parties. We can find them by searching in google. As an example following github repository provides a lot of new color schemes.

https://github.com/flazz/vim-colorschemes
3rd Pary Color Schemes
3rd Pary Color Schemes

LEARN MORE  Compare Vi vs Vim

1 thought on “How To Set, Configure and Use Vim Color Scheme”

Leave a Reply to Adatigish Cancel reply