How to Change Color Scheme in Vim

Last updated: September 5, 2022

Vim is a text editor that can be used to edit all kinds of plain text, especially useful for writing and editing programs. It is also one of the customizable text editors heavily used in the Linux operating system.

The suitable color in the editor helps you to categorize, analyze and identify bugs in the code. You can change color schemes that come with the software package or install vim themes.

In this guide, we learn how to list and change color schemes in VIM.

Prerequisites

  • Vim text editor

If vim is not found installed, run the following command based on your Linux Distribution

sudo yum install vim
sudo apt install vim
  • Terminal or ssh access to your server

List color schemes

Vim installation comes with a number of vim color schemes. Vim color schemes are installed in the /usr/share/vim/vim*/colors directory.

To list all color schemes which are ready-to-use themes, open any document using the Vim editor, type:

:colorscheme [space] [crtl+d]
List color schemes which are installed
List color schemes which are installed

Change color scheme

The default color scheme is hard coded in VIM itself but it looks peachpuff (in light terminal) and ron (in dark terminal).

For instance, to change color scheme to darkblue, you would use:

:colorscheme darkblue
Color scheme - dark blue
Color scheme - dark blue
Color scheme - delek
Color scheme - delek

Download and apply themes

Themes are basically a mixture of different colors which has a nice feel and look. There is a wide variety of color themes that may suit your needs. You can find and download Vim themes from GitHub or websites such as vimcolors.

In the following steps, we are going to download nirvana color scheme and use it.

1. First find folder where vim color scheme are stored during installation.

sudo find / -iname colors

The color are stored inside the directory /usr/share/vim/vim74/colors/

2. Download nirvana from its github page.

sudo yum install –y git
git clone https://github.com/duckwork/nirvana.git

3. Move the scheme configuration to /usr/share/vim/vim74/colors/

sudo mv nirvana/colors/nirvana.vim  /usr/share/vim/vim74/colors/

4. Open any file and just search for nirvana, use:

:colorscheme nirvana
Apply color theme - nirvana
Apply color theme - nirvana

To make this change permanent, update .vimrc file in /etc or in the user's home directory.

Change below the line with your preferred color scheme name:

colorscheme colorscheme_name

To enable the syntax highlight, use:

syntax on

Conclusion

A color scheme can dramatically influence your experience with any text editor. This tutorial guide you to choose and apply colors in vim and accomplish your task in an easier way.

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment