Reputation: 4460
What substitution command should I use, in order to replace every occurrence of the character /
with the string "abc" in a text file with vi?
:1,$ s/?/abc
What should I use instead of the ?
in the above snippet?
Upvotes: 1
Views: 197
Reputation: 16208
You could change the substitution delimiter which is by convention /
to something else then you would not have to escape the forward slash at all -
:%s;/;abc;g
:%s~/~abc~g
:%s!/!abc!g
:1,$s?/?abc?g
:%s/\//abc/g
:1,$sub;/;abc;g
These all do the same replacement of /
with abc
on every line.
Upvotes: 6