How to Set Vim Color Scheme in Linux? [4 Steps]

LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now

To set the Vim color scheme in Linux, follow the steps below:

  1. Open Vim Text Editor with the vim command.
  2. Use :colorscheme command to view available color schemes.
  3. Select the desired color scheme.
  4. Set the color scheme with the :colorscheme [scheme_name] command.

To know each step in detail, go through this article. Here, I will show you how to install the Vim color scheme. Additionally, you will learn how to change, view, control, and make the color scheme permanent.

What is Vim Color Scheme?

The Vim color scheme is one of the unique features of the Vim text editor that determines the color for the syntax highlighting. The color scheme of Vim is composed of different colors that can be selected per choice. Vim color scheme improves the visual experience of the user throughout the code. It enhances the readability of any code by making it easier for the user to recognize variables, keywords, or other code elements.

How to install Vim Color scheme?

There are two ways to install the Vim color scheme. Check them out:

1. Manual Installation

To install the Vim color scheme manually, follow the steps below:

  1. First, create a directory where to download the color scheme file:
    mkdir -p ~/.vim/colors

    The mkdir command with the -p option will create a sub-directory “colors” in the directory “.vim”.

  2. Now, download the color scheme file from the GitHub repository using the wget command:
    wget https://raw.githubusercontent.com/altercation/vim-colors-solarized/master/colors/solarized.vim -O ~/.vim/colors/solarized.vim

    The solarized color scheme has been saved in the /home/mou/.vim/colors directory:
    download new color scheme

2. Using Vim-Plug

To install a solarized Vim color scheme utilizing the Vim-Plug plugin manager, follow the below steps:

  1. First, install the Vim-Plug by following this linked article.
  2. After installing the Vim-Plug, open the .vimrc file with this command:
    vim ~/.vimrc
  3. Now, install plugins for the Vim solarized color scheme by writing the following lines in the .vimrc file:
    call plug#begin('~/.vim/plugged')
    Plug 'altercation/vim-colors-solarized'
    call plug#end()

    install vim color scheme with vim-plug

  4. Save and exit the configuration file with :wq command.
  5. Reopen the .vimrc file and execute :PlugInstall command to successfully install the color scheme plug:
    install vim color scheme with vim-plug2

4 Steps to Set Vim Color Scheme

Here are detailed 4 steps to set the Vim color scheme:

Step 1: Open Vim Text Editor

Open a terminal window with CTRL+T and type Vim to open the Vim text editor:

vim

Step 2: View Color Scheme

To view the Vim color scheme, execute the command below:

:colorscheme

view default color scheme

You will see the default color scheme here.

To see all the available color schemes, run :colorscheme command followed by a space, and then press CTRL+D:

view all color schemes in Vim

Step 3: Select Color Scheme

After viewing all the colors, select your desired color scheme in Vim. In this case, I will select the “solarized” color scheme from the available options:

select vim color scheme

Step 4: Set Vim Color Scheme

Once you have selected the color scheme, set it using :colorscheme [colorscheme_name] command. To set a solarized color scheme, apply the following command in the Vim text editor:

:colorscheme solarized

set vim color scheme

How to Manage Vim Color Scheme?

To use the Vim color scheme effectively and get the most benefit out of it, users should know how to operate it. Here are some crucial operations associated with the Vim color scheme:

A. Set Default Vim Color Scheme

The color scheme changes are temporary. When you close Vim, the color scheme will go back to the default settings. To set the desired color scheme as default and make it persistent, you can follow the steps below:

  1. Set the desired color using Step 4: Set Vim Color Scheme.
  2. Open the .vimrc file and add the following lines to set the solarized color scheme as default:
    syntax on
    set background=dark
    colorscheme solarized
    EXPLANATION
    Here, syntax on enables syntax highlighting. The set background command sets the background color to “dark” and the color scheme is set to solarized.
  3. After that, save and exit the .vimrc file using :wq command to make the color scheme permanent.

B. Change Vim Color Scheme

To change the color scheme, use :colorscheme [colorscheme_name] command. For example, to change it from solarized to blue, type this line:

:colorscheme blue

change color scheme

After writing the command, press ENTER to get the output as follows:
change color scheme to blue

Now, to change the “blue” color scheme to “morning”, execute :colorscheme morning command:

change color scheme to morning

Thus, you can change the color scheme in Vim.

C. Control Vim Color Scheme

To control the Vim color scheme, use the highlight command. It can alter the whole color scheme or a part of it. For instance, to turn the text color “red” from the default color, run the following command from the normal mode in Vim:

:highlight Normal ctermfg=Red

highlight text color red

You can also set the background color scheme from default to “red” with the highlight command. Here’s how:

:highlight Normal ctermbg=Red

customize color scheme using highlight command

To see the list of Vim’s default highlight groups, run this command:

:help highlight-groups

Conclusion

To wrap up, I have explained the basics of the Vim color scheme to ease the life of Vim users. I have also added how to install the Vim color scheme, and how to set, and install it. By reading this article, you will know everything about the color schemes for the Vim text editor. Happy reading!

People Also Ask

How to Make the Vim Color Scheme Persistent?

To make the Vim color scheme persistent, write colorscheme [colorscheme_name] in the .vimrc file. Then save and exit the configuration file using :wq command.

How do I install a color scheme file in Vim?

To install a color scheme in Vim, download the desired scheme using the wget command. After that, add the plug script to the .vimrc file and save it.

How to highlight text in Vim?

To highlight text in Vim, use the highlight command. This command can change the text color as well as the background color.

Related Articles


<< Go Back to Vim in LinuxLinux Text Editors | Learn Linux Basics

5/5 - (1 vote)
Mitu Akter Mou

Hello, This is Mitu Akter Mou, currently working as a Linux Content Developer Executive at SOFTEKO for the Linuxsimply project. I hold a bachelor's degree in Biomedical Engineering from Khulna University of Engineering & Technology (KUET). Experiencing new stuff and gathering insights from them seems very happening to me. My goal here is to simplify the life of Linux users by making creative articles, blogs, and video content for all of them. Read Full Bio

Leave a Comment