Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Easy fix--I just needed to escape the ampersand: :%s/ -- /\—/g –  Joe Mornin Jan 17 '12 at 16:23
    
are you not allowed to give yourself an answer (instead of a comment)? –  akira Jan 17 '12 at 16:59
    
@morninj your ampersand is not even in your substitution string. Did you forget it in your question? –  tidbeck Jan 17 '12 at 19:58
    
@akira Since I'm below a reputation threshold, I have to wait 8 hours before adding an answer. –  Joe Mornin Jan 17 '12 at 20:59
1  
FYI, vim-textcov has some functions to do this for you. –  idbrii Dec 5 '12 at 18:10

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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