tags:

views:

63

answers:

2

I've a file that was exported from Word and it replaced all quotes with strange unicode characters which aren't correctly displayed in vim. So now I want those characters to be replaced with quotes, but I don't know how to enter this character in

:%s/???/'/g

The characters look like this: ~U ~R. But of course I can't just mark them with mouse and paste in the command.

+1  A: 

You can try setting the encoding type and see if it fixes the visalizations of those characters:

:set encoding=utf-8

then you can use them directly. Alternatively, you can place your cursor on the unprintable character and hit ga, it will show the decimal/hex/octal code of that character, then you can substitute it with:

:%s/\%xYY/substitute/g

where YY is the hex code of the char, if it's multibyte:

:%s/\%uYYYY/substitute/g

for details:

:help character-classes
kemp
+3  A: 

I usually:

  1. delete the character with: x
  2. undo my change with: u
  3. do the substitute thanks to *c_CTRL-R*: :%s/^R"/'/g
Luc Hermitte
Equivalently, you can also do `y` followed by space instead of `xu`, but whichever works for you.
Al
Thanks Al! I've always wondered how to do this without a `vy` or a `xu`
Luc Hermitte
Also `yl` (`l` is for letter). And also `y<right>`, but that one is kind of awkward.
Brian Carper