How to get Vim to highlight non-ascii characters?

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

    Someone already have answered the question. However, for others that are still having problems, here is another solution to highlight non-ascii characters in comments (or any syntax group in the matter). It's not the best, but it's a temporary fix.

    One may try:

    :syntax match nonascii "[^\u0000-\u007F]" containedin=ALL contained |
                \ highlight nonascii ctermfg=yellow guifg=yellow
    

    This has mix parts from other solutions. You may remove contained, but, from documentation, there may be potential problem of recursing itself (as I understand). To view other defined patterns, syn-contains section would contain it.

    :help syn-containedin
    :help syn-contains 
    

    Replicated issue from: Set item to higher highlight priority on vim

提交回复
热议问题