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

前端 未结 4 694
鱼传尺愫
鱼传尺愫 2021-02-04 06:33

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

相关标签:
4条回答
  • 2021-02-04 06:54

    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

    0 讨论(0)
  • 2021-02-04 06:57

    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.

    0 讨论(0)
  • 2021-02-04 07:11

    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.

    0 讨论(0)
  • 2021-02-04 07:16

    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.

    0 讨论(0)
提交回复
热议问题