Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Vim can you stop the color change of white space characters with 'set cursorline' on?

In this Vim screenshot you can see that when moving the cursor over a line it changes the normal color of the whitespace characters (shown on the left) from grey to black. Can I stop this and leave them showing grey always, regardless of cursor position?

enter image description here

I've tried setting these in the colour scheme but no luck:

hi SpecialKey  guibg=bg  guifg=#CCCCCC gui=none
hi NonText     guibg=bg  guifg=#CCCCCC gui=none
like image 899
Gary Willoughby Avatar asked Nov 23 '11 20:11

Gary Willoughby


2 Answers

You can use :match to highlight the tabs.

:match NonText '^\s\+'

That seems to override the cursor line. It would be better of course to use matchadd() but it seems to be overriden by the cursor line. There might be a way to make it work

like image 159
mb14 Avatar answered Oct 11 '22 05:10

mb14


Following lines in .vimrc fixed the problem for me.

au VimEnter * call matchadd('SpecialKey', '^\s\+', -1)
au VimEnter * call matchadd('SpecialKey', '\s\+$', -1)

It overrides other styles application for tabs and trailing spaces inside a cursor line.

like image 23
Igor Mikushkin Avatar answered Oct 11 '22 05:10

Igor Mikushkin