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

我的梦境 提交于 2019-12-03 09:02:44

问题


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?

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

回答1:


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




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/8248872/in-vim-can-you-stop-the-color-change-of-white-space-characters-with-set-cursorl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!