How to change font color for comments in Vim

Syntax HighlightingVim

Syntax Highlighting Problem Overview


I'd like to change the default font color for comments, which is dark blue to slightly yellow color. It is difficult to read on the black background. I'm using xfce4-terminal, not gvim with GUI.

How do I change only this one color?

So far, I have changed the settings in my ~/.profile file according to "256 colors in vim" using:

if [ -e /usr/share/terminfo/x/xterm-256color ]; then
        export TERM='xterm-256color'
else
        export TERM='xterm-color'
fi

and

set t_Co=256

in ~/.vimrc.

Syntax Highlighting Solutions


Solution 1 - Syntax Highlighting

Most well-behaving colorschemes will respect the background setting.

set background=dark

would change the color of comments from dark blue to light blue, when using the default colorscheme.

Solution 2 - Syntax Highlighting

:hi Comment guifg=#ABCDEF

Pick your color! If using a color terminal, replace guifg=#ABCDEF with ctermfg=N with N being a color number.

Also type :help :hi for more information.

Solution 3 - Syntax Highlighting

hi Comment ctermfg=LightBlue

Add this to your .vimrc file which is either in your ~ or the /etc/vim directory. This will make it permanent. I haven't tested this with gvim.

I also have set background=light before I set comment color. I like all the colors it created except for the comments.

Solution 4 - Syntax Highlighting

After searching you can find a decent reference to Vim regarding this issue especially, at "256 colors in vim".

Start with:

:verbose hi

when actually inside Vim, and editing a file.

Then check out how all of the variables have metadata associated with them. Data returned from there makes it real easy to add the desired modifier types into .vimrc. As an example, these are updates I recently added in order to get rid of dark blue, and not have to be tormented by the light blue:

set number background=dark
syntax on
highlight Comment    ctermfg=119
highlight Identifier ctermfg=99AA00

Solution 5 - Syntax Highlighting

If the objective is to make it more readable in the dark background of the text console, the command below is a wonderful option and easy to remember:

:colorscheme evening

But be advised, it will change other element's colors.

Solution 6 - Syntax Highlighting

See "Syntax Highlighting In VIm".

set background=dark

or

set bg=dark

are the best solution for VIM users!

Solution 7 - Syntax Highlighting

There are various color schemes in Vim. The "default" color scheme displays comments in a blue color, which makes it hard to read against a black terminal background. I prefer to use the "desert" color scheme which displays in readable colors.

To enable the "desert" color scheme in Vim, use the command :color desert. If you want to go back to the default use :color default.

You can even update your ~/.vimrc with your preferred color scheme using:

echo 'color desert' >> ~/.vimrc

Solution 8 - Syntax Highlighting

You can check your color scheme first using:

:!ls $VIMRUNTIME/colors

then try whichever suits you best.

Solution 9 - Syntax Highlighting

I had the same question and wanted to edit my Comment color from LightBlue to something more toned down, and, following @Benoit's answer, this worked for me:

hi Comment ctermbg=0 ctermfg=DarkGrey
                 

I saved it in my ~/.vimrc file.

0 = Black Background, i.e. Color Terminal Background: ctermbg=0, and the Foreground text is DarkGrey, i.e. Color Terminal Foreground: ctermfg=DarkGrey.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionxralfView Question on Stackoverflow
Solution 1 - Syntax Highlightingmike3996View Answer on Stackoverflow
Solution 2 - Syntax HighlightingBenoitView Answer on Stackoverflow
Solution 3 - Syntax HighlightingGauravView Answer on Stackoverflow
Solution 4 - Syntax HighlightingDouglas RandallView Answer on Stackoverflow
Solution 5 - Syntax HighlightingGermanoView Answer on Stackoverflow
Solution 6 - Syntax HighlightingRusHughesView Answer on Stackoverflow
Solution 7 - Syntax HighlightingrashokView Answer on Stackoverflow
Solution 8 - Syntax HighlightingVladimir ValchevView Answer on Stackoverflow
Solution 9 - Syntax HighlightingArtemisia AbnusView Answer on Stackoverflow