Occasionally I run across weird characters in Vim that show up as numbers in angle brackets — <95> or <97>, for example. They’re just curly quotes and em-dashes and such, but they’re encoded oddly, and there’s no way easy to do a search and replace on them.

Except that there is.

  1. Yank the character. (That’s Vim talk for copying to the clipboard.)
  2. Start typing your search-and-replace command — :%s/
  3. Hit Ctrl-R followed by " (double quotes) to paste the character.
  4. Finish out the rest of the search-and-replace and hit Enter — :%s/<97>/--/g

Voila. (There might be a way to fix these characters with iconv or some other encoding app, but I haven’t been able to get it to work other than this way.)