How to Change Comment Color in Vim – Fix Unreadable Blue Color

Written by: Bobbin Zachariah   |   Last updated: August 13, 2022

Are you annoyed about the comment color in vim? The dark blue color of the comment is often hard to read.

In this tutorial, we learn how to change the comment color in Vim. There are few methods we can use to look vim comment very readable.

Method 1: Use a different color scheme

There are many color schemes available in vim. You can use a different color scheme using the :color command. The color scheme desert is more pleasant to read.

To change color scheme to desert, open vim and enter:

:color desert
Vim comment in blue
After changing color scheme to desert

From the output, you can see the comments are very clear to read.

To make this change permanent create a hidden file named .vimrc in your home folder and add the below line:

color desert

Different color schemes are available under the directory /usr/share/vim/vim<version>/colors/.

list vim color schemes directory
List vim color schemes directory

Alternatively, you can see the available color schemes by opening vim and type :color <space> <press tab key> .

Method 2: Change terminal Background

You can change the default light background to dark. Open vim and add below line

:set background=dark

Method 3:  Using highlight comment command

You can use the highlight comment command to change the vim comment color. For example to change to vim comment to green, type:

:highlight Comment ctermfg=green
vim comment in green
vim comment in green

If using GUI vim, you can use hex color codes:

:highlight Comment guifg=#a26a4d

Conclusion

In this tutorial, we learned how to change comment color in vim. Thanks for reading, please leave your feedback and suggestions in the comment section.

About The Author

Bobbin Zachariah

Bobbin Zachariah

Bobbin Zachariah is an experienced Linux engineer who has been supporting infrastructure for many companies. He specializes in Shell scripting, AWS Cloud, JavaScript, and Nodejs. He has qualified Master’s degree in computer science. He holds Red Hat Certified Engineer (RHCE) certification and RedHat Enable Sysadmin.

SHARE

Comments

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

Leave a Reply

Leave a Comment