Problem :
I was wondering how I would search and replace all /’s with -‘s in vi.
%s///-/g doesn’t work obviously.
Solution :
Try escaping your /s, with a .
/
. yes, it looks awful. That’s how I remember it 😛
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.