Skip to content

Instantly share code, notes, and snippets.

@dergachev
Created July 10, 2013 15:40
Show Gist options
  • Save dergachev/5967375 to your computer and use it in GitHub Desktop.
Save dergachev/5967375 to your computer and use it in GitHub Desktop.

First, highlights all search matches:

:set hlsearch

The following searches (and possibly highlight) any non-printable characters:

/[^[:print:]]

To highlight these guys in red, type the following:

:match Error /[^[:print:]]/

To turn this off:

:match Error //

The following pumps the current line through hexdump, which gives the unicode hex codes for each character:

:.w !hexdump

Alternatively to hexdump, you can place your cursor over a suspicious character and type 'ga' which will show you its unicode code.

In theory you can do ":set list" and ":set nolist" to highlight funky characters, but by default that only highlights EEOL with $. To make it slightly more useful:

:set listchars=eol:¶,tab:>-,extends:»,precedes:«,trail:•

:set list

:set nolist

See ":help listchars" or https://wincent.com/blog/making-vim-highlight-suspicious-characters

To highgliht invisible character colors:

:highlight NonText guifg=#4a4a59
:highlight SpecialKey guifg=#4a4a59

In our case, it was OBJECT REPLACEMENT CHARACTER, aka U+FFFC aka ef bf bc that was the problem.

We can search for it specifically using the key combo to input special chars into vim:

/<CONTROL-V>UFFFC<ENTER>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment