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.

I was wondering how I would search and replace all /'s with -'s in vi.

%s///-/g doesn't work obviously.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Try escaping your /s, with a \.

\/. yes, it looks awful. That's how I remember it :P

share|improve this answer

You can use any delimiter you wish, not just /. For example, !:

%s!/!-!g

This way, / becomes non-special and doesn't have to be escaped.

share|improve this answer

replacing separator is not always /.

Try

%s;hoge/hoge;fuga/fuga;g

in the text of "http://hoge/hoge"

share|improve this answer
    
that has already been said by ephemient –  accolade Jan 16 '12 at 23:30

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.