Using the concept of the code below in VIM How do I make the tabs a light grey background and a the spaces a blue background
" part of ~/.vimrc
" highlight tabs and trailing spaces
set listchars=tab:>-,trail:-
set list
If you use those options in your ~/.vimrc
you most certainly have read :help 'list'
and :help 'listchars'
but from your question it's not really clear if you spotted the last two lines of :help 'listchars'
:
The "NonText" highlighting will be used for "eol", "extends" and
"precedes". "SpecialKey" for "nbsp", "tab" and "trail".
Tabs and trailing spaces use the same highlight group, though, so you won't be able to give them different background colors with those highlight groups. But you don't really need different colors, here, because you already set them to be represented by different characters.
this is one way:
first create two hi-groups:
:hi GroupA ctermbg=blue ctermfg=.. guibg=...
:hi GroupB ctermbg=gray ctermfg=.. guibg=..
then
:match GroupA / \+$/
:2match GroupB /\t/
You can't, at least not in an easy way that is 100% correct.
As @romainl has said, Vim only offers one highlight group for all listchar types representing characters, viz. SpecialKey
.
The workaround implementation of @Kent has several shortcomings:
:autocmd
s to define it for new windows, too.'list'
is actually set; hooking into its changes isn't directly possible.:match
slots; this could be prevented via matchadd()
, but its use is more complex.So, think hard whether that feature is really worth it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With