I\'m trying to get Vim to highlight non-ASCII characters. Is there an available setting, regex search pattern, or plugin to do so?
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:]]/
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