changing the color of comments in vim

Adding this to ~/.vimrc makes the blue a tad brighter (and readable) in my black-backgrounded terminals thus far:

hi comment ctermfg=blue

(Had the same "can't read blue-on-black probs described in original post until employing above. Simple to operationalize when continually working in new accounts/machines like I do. This answer may be more robust for "proper" account setup, but changes the comment to color to red, and seems to require more work to employ.)


Create your own colour scheme. The easiest way to do this is to copy an existing one and tweak the line that specifies the colour. For most colour schemes, this will typically look something like this:

hi Comment  guifg=#80a0ff ctermfg=darkred

Simply change this to whatever colour you want. If you're using the default colour scheme, you could simply make a new one called (e.g.) ~/.vim/colors/suresh.vim (the path will need to be different if you're on Windows - see :help rtp) with contents like this:

hi clear
if exists("syntax_on")
    syntax reset
endif

let colors_name = "suresh"

hi Comment  guifg=#80a0ff ctermfg=darkred

I've created a colour scheme that uses a slightly different declaration format to make it a bit easier to edit (the standard one gets a bit difficult to maintain with a lot of colours and support for light and dark backgrounds). This is available here if you're interested. This self highlights, so it's easy to make a change, enter :w and see the colour that will actually be highlighted. However, if you just want to change one colour, it may be easier to just stick to the examples above.


The Ubuntu terminal has a dark purple background by default, and comments in Vim are basically unreadable.

Using the following setting, either in ~/.vimrc or directly in vim (after pressing the : key) sorted out the problem for me:

set background=dark

Tags:

Vi

Vim