How to get Vim to highlight non-ascii characters?

前端 未结 8 1149
萌比男神i
萌比男神i 2020-11-29 15:14

I\'m trying to get Vim to highlight non-ASCII characters. Is there an available setting, regex search pattern, or plugin to do so?

8条回答
  •  眼角桃花
    2020-11-29 16:03

    Yes, there is a native feature to do highlighting for any matched strings. Inside Vim, do:

    :help highlight
    :help syn-match
    

    syn-match defines a string that matches fall into a group. highlight defines the color used by the group. Just think about syntax highlighting for your vimrc files.

    So you can use below commands in your .vimrc file:

    syntax match nonascii "[^\x00-\x7F]"
    highlight nonascii guibg=Red ctermbg=2
    

提交回复
热议问题