15

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
General Grievance
  • 4,555
  • 31
  • 31
  • 45
Gary Willoughby
  • 50,926
  • 41
  • 133
  • 199

4 Answers4

3

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

mb14
  • 22,276
  • 7
  • 60
  • 102
1

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.

Igor Mikushkin
  • 1,250
  • 16
  • 25
0

Yes you can. From :help listchars (at the end):

The "NonText" highlighting will be used for "eol", "extends" and "precedes". "SpecialKey" for "nbsp", "tab" and "trail".

With this knowledge you can modify your color scheme accordingly or add a call to highlight in your vimrc.

david
  • 5,919
  • 1
  • 17
  • 7
-1

I believe you have 'cursorline' set. The CursorLine highlight group defines the highlights for the same. Either you set nocursorline, (which can speed line movements) or change the CursorLine highlight groups fg colors.

Dhruva Sagar
  • 7,089
  • 1
  • 25
  • 34
  • The `CursorLine` highlight group overrides whitespace characters regardless of its fg colours. I believe this is precisely the problem the OP is facing – Zoey Hewll May 26 '18 at 05:03