3

I have set listchar in .vimrc as below:

set list  lcs=tab:→\ ,space:·,nbsp:␣,eol:¶

How can I display these characters →\ , · , , with red color? Here is my failed attempt:

hi! set list  lcs=tab:→\ ,space:·bsp:␣,eol:¶   ctermbg=red  guibg=red
1
  • 2
    :h hl-SpecialKey
    – Matt
    Jul 18, 2020 at 9:18

1 Answer 1

4

You need to do this in two steps. You got the first one right by setting list and listchars.

The problem comes when you apply the highlight: you cannot combine the commands the way you are trying to.

As Matt pointed in his comment, the highlight group responsible for listchars characters is SpecialKey.

" Enable
set list
set listchars=tab:→\ ,space:·,nbsp:␣,eol:¶


" Highlight
highlight SpecialKey ctermfg=blue ctermbg=red guifg=blue guibg=red

As you can see, I separated the settings in several lines and expanded them to their long name for more clarity, which is arguably more appropriate if you want to put these lines in a vimrc.

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.