How to get Vim to highlight non-ascii characters?

前端 未结 8 1183
萌比男神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:46

    For other (from now on less unlucky) folks ending up here via a search engine and can't accomplish highlighting of non-ASCII characters, try this (put this into your .vimrc):

    highlight nonascii guibg=Red ctermbg=1 term=standout
    au BufReadPost * syntax match nonascii "[^\u0000-\u007F]"
    

    This has the added benefit of not colliding with regular (filetype [file extension] based) syntax definitions.

提交回复
热议问题