2

I'm trying to use the substitute command in VIm but don't get the result I excpect: I'm editing an html file, and for example I'd like to replace all "é" characters by the é code (yes it's in French and yes I really like to complicate my life :).

Then I use this command: :s /é /é /gc to replace all é by é in the line with asking for confirmation. This time it says the pattern hasn't been found, but when it finds it, it adds and don't replace, so the result is that the word "piétons" is replaced by the word "piéétons" ... the character é isn't deleted.

Can someone explain what I'm doing wrong please?

substitute command in VIm 01

substitute command in VIm 02

2 Answers 2

5

You have to escape the & sign. Try that:

:s /é /\é /gc

Notice, I don't know if it is desired, but your substitution only replaces é if it is followed by a space. To replace all é's, use that command (without the spaces):

:s /é/\é/gc
1
  • That works great, the space was an error, I thought it was necessery for the substitute command. Thanks a lot!
    – tasseb
    Feb 6, 2015 at 11:25
0

... or install recode and

:%!recode -d utf-8..html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .