Vim highlights the background of certain words (e.g. when doing spellchecking) in a way that I would like to change (because the background and the word itself are almost of the same color, which makes the whole thing illegible). How is it possible to determine which "background" (?) highlighting group (?) vim is using, so that it can be customized?

I did find an apparently similar-looking question, but its answer does not offer the simplest response (Ralf's answer below is simpler already), and more importantly, it doesn't cover the colors of the background (it displays the highlighting group of the text foreground).

  • I put together vim-synstax for this, though I believe it relies techniques similar to the posted answer under the hood.
    – D. Ben Knoble
    Jan 4, 2019 at 15:10
  • Just because an answer isn't simple doesn't mean it isn't correct...
    – jamessan
    Jan 4, 2019 at 15:40
  • 4
  • Just because an answer isn't simple doesn't mean there isn't any simple answer. :) The answer by Ralf below is already about 3 times simpler. Jan 4, 2019 at 16:42
  • More importantly, the answer you link to is about the text foreground, whereas the text background is what is problematic and not reported by the answer. Jan 4, 2019 at 16:52

1 Answer 1


I have the following in my vimrc:

command SynID  echo synIDattr(synID(line("."), col("."), 1), "name")

Move the cursor to the word you are interested in and then execute :SynID.

The spell checker can set the background of the word independently. It uses the names "SpellBad", "SpellCap", "SpellLocal" and "SpellRare". Definition can be printed with :highlight SpellBad, etc., so that you can probably recognize which style is used by the spell checker that causes a problem for you. Also see :help hl-SpellBad.

  • That's very close to the solution I was referring to in the question: do you know by any chance of any more direct way of getting the same information? Jan 4, 2019 at 13:12
  • PS: This doesn't actually give all the information needed: for example, the cursor is in a vim comment and some of the words are highlighted, and this returns "vimComment" on both highlighted and non-highlighted words. Maybe what I am looking for here is not a "highlighting group"? Or maybe more information can be obtained? Jan 4, 2019 at 13:18
  • Strange. I have this vim comment: " Mapping: This is a "Test". On Mapping it returns "vimCommentTitle", on "Test" it returns "vimCommentString" and on the rest of the line it returns "vimLineComment".
    – Ralf
    Jan 4, 2019 at 13:26
  • I observe the same. Now I am pretty sure that what I need to have is the style of the text background (not of the text per se), which is set by the spell checker. I'll update the question. Jan 4, 2019 at 16:47
  • @EricLebigot The spell checker uses the names "SpellBad", "SpellCap", "SpellLocal" and "SpellRare". Definition can be printed with :highlight SpellBad etc. Also see :help hl-SpellBad.
    – Ralf
    Jan 4, 2019 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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