TransWikia.com

How to show list characters with red color?

Vi and Vim Asked on August 31, 2021

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

One Answer

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 do (as far as I know).

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

set list
set listchars=tab:→ ,space:·,nbsp:␣,eol:¶
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 seems more appropriate if you want to put these lines in a vimrc.

Correct answer by Biggybi on August 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP