11

I am using spell checker in vim, and I find one feature very annoying: errors are being highlighted with some weird color, which is nowhere to be found in gnome terminal settings:

highlighted error


I would like to change the highlight color to something else, so it doesn't obscure the wordd, without changing my global font color. How can I configure this?

10

The SpellBad highlighting group should allow you to configure the appearance of misspelled words.

Let's say you want them to be red on yellow background. Then you could add the following code somewhere in your vimrc file or in your colorscheme file (but in any case after the colorscheme has set up the SpellBad group, otherwise it would override your settings):

:highlight clear SpellBad
:highlight SpellBad ctermfg=009 ctermbg=011 guifg=#ff0000 guibg=#ffff00

The ctermfg, ctermbg arguments control the colors of the foreground and background colors in a terminal while guifg, guibg do the same for vim inside a gui.

For the terminal, the colors can be expressed with a name (red, yellow...) or a decimal code between 000 and 007 / 015 / 255 when it supports 8 / 16 / 256 colors. You can check how many colors it supports from vim with: echo &t_Co

For a gui, the colors can be expressed with a name or a code in hexadecimal.

Here's a chart which shows codes for some colors.

There are other highlighting groups (SpellCap, SpellLocal and SpellRare) which control the appearance of other kinds of words.

Note that setting the 'background' option causes your colorscheme to be reloaded. So if you have set background=dark somewhere in your vimrc, put the previous code which changes the SpellBad group after that line, otherwise the colorscheme will again override your settings.

For more information, see:

:help hl-SpellBad

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.