by tomxor · 5y ago · 0 comments
I thought this was default but just realised it only does the <FFFF> thing when there is no printable glyph available.
Allowing printable unicode in strings seems like a nice balance if it can be done reliably.
highlight link NonASCII Error
autocmd Syntax * :syntax match NonASCII "[^\d0-\d127]"
Obviously haven't been using it long, and I'm not confident enough in my vim knowledge to vouch for its correctness, but it works in the limited amount of scenarios I tested so far. fun! HighlightNonAscii()
if &ft =~ 'markdown\|text'
return
endif
syntax match nonascii "[^\x00-\x7F]"
highlight nonascii guibg=#ff2232 guifg=#000000
endfun
autocmd BufEnter * call HighlightNonAscii()
Your version might depend on your frontend (gui, terminal...). And you might want to filter more file types.