Vim is one of the most powerful UNIX text editors you can master. It’s the successor of the vi text editor (available on all UNIX systems). Vim is free and open-source with tons of features and customization options. In fact, it comes with everything that you’d expect from any modern text editor. There are also numerous add-ons available to extend the functionalities.In this guide, we are going to focus on the Vim color schemes.

Vim Color Schemes

For any modern text editor, syntax highlighting is a powerful feature. Proper syntax highlighting greatly benefits those who have to work with codes and texts for a prolonged period of time. Vim comes with a default color scheme for a lot of programming languages. There are also third-party color schemes available.

To enjoy the colorful syntax highlighting, however, you have to have it enabled. Learn more about enabling syntax highlighting in Vim. To test if the syntax highlighting is on, grab a sample code and open it in Vim. For demonstration, I’ve grabbed sample3.sh from File Samples.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image8-10.png" data-lazy- height="462" src="data:image/svg xml,” width=”972″>

As the output shows, Vim is correctly highlighting the keywords in the script. As we’ve not introduced any additional color scheme, it’s using the default one.

If the syntax highlighting isn’t working, then run the following Vim command:

To permanently enable syntax highlighting, add the following directive to the vimrc file:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image10-7.png" data-lazy- height="390" src="data:image/svg xml,” width=”852″>

Changing Vim Color Scheme

By default, Vim comes with a bunch of color schemes. For the most part, these default color schemes may be sufficient for your needs. In the first section, we’ll have a look at listing all the available color schemes.

Listing available color schemes

To list all the color schemes, enter the following Vim command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image9-8.png" data-lazy- height="358" src="data:image/svg xml,” width=”967″>

After typing the command, press “Tab”. This will open a list of all the available color schemes. If you keep pressing “Tab”, Vim will cycle through all of them.

Once you’ve decided, use the following command structure to apply it to the Vim session:

$ :colorscheme <color_scheme_name>

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image12-5.png" data-lazy- height="360" src="data:image/svg xml,” width=”972″>

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image11-6.png" data-lazy- height="355" src="data:image/svg xml,” width=”972″>

Vim supports abbreviations of many of its commands. We can use the following abbreviation of colorscheme to speed things up:

$ :colo <color_scheme_name>

Setting the default Vim color scheme

In the previous section, we showcased changing the color scheme of Vim. Unfortunately, the change will only last for the current Vim session. How do we make it a permanent change?

Remember how we enabled syntax highlighting enabled permanently? Yes, the same vimrc trick is going to be relevant here. The vimrc file, similar to bashrc, is loaded every time Vim starts, applying all the configurations.

To enable the color scheme darkblue as the default, add the following code on the vimrc file:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image2-17.png" data-lazy- height="358" src="data:image/svg xml,” width=”854″>

Note that it should be accompanied by the “syntax on” directive so that the new color scheme is always applied.

To take the changes into effect, restart Vim. If that’s not an option, then you can try reloading the vimrc file using the following Vim command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image1-19.png" data-lazy- height="361" src="data:image/svg xml,” width=”852″>

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image4-15.png" data-lazy- height="358" src="data:image/svg xml,” width=”853″>

Adding new color schemes

Vim allows third-party color schemes to be applied. Thanks to the awesome community, Vim has an extensive collection of color schemes.

There are many places you can grab Vim color schemes from. There are some dedicated places for Vim color schemes, for example, vimcolorschemes, vimcolors, etc.

For demonstration, let’s add papercolor-theme to Vim. The necessary packages can be found on papercolor-theme on GitHub.

The following Git command will clone the repo contents to the proper location. Learn more about Git repo cloning.

$ git clone https://github.com/NLKNguyen/papercolor-theme.git ~/.vim/pack/colors/start/papercolor-theme

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image3-16.png" data-lazy- height="265" src="data:image/svg xml,” width=”1036″>

Vim should now recognize the color scheme.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image7-12.png" data-lazy- height="355" src="data:image/svg xml,” width=”613″>

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image5-15.png" data-lazy- height="358" src="data:image/svg xml,” width=”609″>

To make it the default color scheme, update the vimrc file:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image6-14.png" data-lazy- height="363" src="data:image/svg xml,” width=”619″>

Final Thoughts

This guide demonstrates managing the color schemes in Vim. It comes with a handful of color schemes by default. However, you can also add your favorite one from the internet. We demonstrated how to grab and configure a third-party color scheme in Vim.

Note that these color schemes are regularly updated. The method demonstrated here will leave you stuck on the same version. To tackle this issue, there are Vim plugin managers available that will automatically install, update and load the plugins of your choice.  Learn more about the Vundle plugin manager for Vim. There are also other websites like Vim Awesome that keep a catalog of numerous Vim plugins.

Happy Computing!

About the author

<img data-del="avatar" data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/profile-photo-1-150×150.jpg" height="112" src="data:image/svg xml,” width=”112″>

Sidratul Muntaha

Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.