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

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

link|improve this question

17% accept rate
feedback

3 Answers

up vote 3 down vote accepted

Try escaping your /s, with a \.

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

link|improve this answer
feedback

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.

link|improve this answer
feedback

replacing separator is not always /.

Try

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

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

link|improve this answer
that has already been said by ephemient – accolade Jan 16 at 23:30
feedback

Your Answer

 
or
required, but never shown

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