In Vim, I'm trying to run a substitution on this text:

lorem ipsum -- dolor sit

...to get it to look like this:

lorem ipsum—dolor sit

I'm trying to do :%s/ -- /—/g, but it leaves me with this:

lorem ipsum -- —dolor sit

How should I adjust my substitution syntax?

link|improve this question

Easy fix--I just needed to escape the ampersand: :%s/ -- /\—/g – Joseph Mornin Jan 17 at 16:23
are you not allowed to give yourself an answer (instead of a comment)? – akira Jan 17 at 16:59
@morninj your ampersand is not even in your substitution string. Did you forget it in your question? – tidbeck Jan 17 at 19:58
@akira Since I'm below a reputation threshold, I have to wait 8 hours before adding an answer. – Joseph Mornin Jan 17 at 20:59
@morninj: then now is the time :) – akira Jan 18 at 7:24
feedback

1 Answer

up vote 1 down vote accepted

Easy fix--I just needed to escape the ampersand: :%s/ -- /\—/g

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.