xralf
xralf

Reputation: 3752

How to change font color for comments in Vim

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.

Upvotes: 110

Views: 111340

Answers (10)

mat
mat

Reputation: 1

To turn off color:

edit .vimrc file and enter this line as shown below - save and quit

$ vi .vimrc :syntax off

Upvotes: 0

Vladimir Valchev
Vladimir Valchev

Reputation: 657

You can check your color scheme first using:

:!ls $VIMRUNTIME/colors

then try whichever suits you best.

Upvotes: 0

rashok
rashok

Reputation: 13474

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

Upvotes: 1

RusHughes
RusHughes

Reputation: 1181

See "Syntax Highlighting In VIm".

set background=dark

or

set bg=dark

are the best solution for VIM users!

Upvotes: 5

Germano
Germano

Reputation: 87

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.

Upvotes: 7

Douglas Randall
Douglas Randall

Reputation: 101

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

Upvotes: 10

mike3996
mike3996

Reputation: 17537

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.

Upvotes: 154

Artemisia Abnus
Artemisia Abnus

Reputation: 1

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.

Upvotes: 0

Gaurav
Gaurav

Reputation: 753

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.

Upvotes: 61

Benoit
Benoit

Reputation: 79233

: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.

Upvotes: 74

Related Questions