Show space character through listchars only for leading spaces

Is it possible to have my editor in Vim (when editing files .cand .h), show through a listcharsspecial character only for leading space characters?

I found a separate post in which it was noted that starting with version 7.4 Vim now supports highlighting all space characters through listchars. Here is my current variable listchars:

set list listchars=tab:>-,trail:.,extends:>,precedes:<,space:.

And here is a render of how it appears on my screen:

It is displayed on my screen.

However, I would like it to look like this (below), where listcharsonly leading spaces are displayed through , and spaces that occur after spaces are not displayed. i.e:

Desired behavior

, , .vimrc?


diff , - :

Image diff in case the difference is not obvious due to low contrast

+4
1

, linechars , :

highlight WhiteSpaceBol guibg=lightgreen
match WhiteSpaceBol /^ \+/

, .

, ·, :

set listchars=space:·
highlight WhiteSpaceBol guifg=blue
highlight WhiteSpaceMol guifg=white
match WhiteSpaceMol / /
2match WhiteSpaceBol /^ \+/

·! ( white , , blue ).

. Vim, ( ) guibg ctermbg .

+7

Source: https://habr.com/ru/post/1660242/


All Articles