How to get Vim to highlight non-ascii characters?

前端 未结 8 1138
萌比男神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 15:57

    This regex works as well. It was the first google hit for "vim remove non-ascii characters" from briceolion.com and with :set hlsearch will highlight:

    /[^[:alnum:][:punct:][:space:]]/
    
    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题