How to get Vim to highlight non-ascii characters?

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

    If you are interested also in the non printable characters use this one: /[^\x00-\xff]/

    I use it in a function:

     function! NonPrintable()
       setlocal enc=utf8
       if search('[^\x00-\xff]') != 0
         call matchadd('Error', '[^\x00-\xff]')
         echo 'Non printable characters in text'
       else
         setlocal enc=latin1
         echo 'All characters are printable'
       endif
     endfunction
    

提交回复
热议问题