Papouche Guinslyzinho
Papouche Guinslyzinho

Reputation: 5458

vim text replacement : :%s/é/&&eacute/g foreign language

I have a text with multiple french character: I'm trying to replace all the occurrences for an HTML code

example été to get => été right now I'm having either error or a weird text

:%s/é/&é/g  => this gives me a ééeacute;tééeacute;
:%s/é/&é/g  => this gives me a éeacute;téeacute;
:%s/é//é/g  => this gives me an error Trailling character

Upvotes: 0

Views: 62

Answers (1)

romainl
romainl

Reputation: 196781

In the replacement part, & is special, it represents the whole match:

J'ai mangé du paté de campagne.

:s/é/&´/g
J'ai mangéacute; du patéeacute; de campagne.

Escape it to obtain the desired &:

:s/é/\´/g
J'ai mang´ du paté de campagne.

Upvotes: 1

Related Questions