Reputation: 909
I've been using the following to replace characters:
To find each occurrence of eth0
in the current line only, and replace it with br0
,enter (first press Esc key and type):
:s/eth0/br0/g
To find and replace all occurrences of eth1
with br1
, enter:
:%s/eth1/br1/g
To find and replace all occurrences of eth1
with br1
, but ask for confirmation first, enter:
:%s/eth1/br1/gc
To find and replace all occurrences of case insensitive eth1
with br1
, enter:
:%s/eth1/br1/gi
However, how would I replace a string with one that has a /
in it. For example, I want
to replace all my debug printf statements with //
. When I type..
:%s/printf/ // /gc
it gives me a Trailing characters error. If someone could teach me how to do this i would be thankful.
Thank You!
Upvotes: 0
Views: 85
Reputation: 195059
escape the /
in :s/.../../
or better, use other separator:
e.g. s:@...@...@g
Upvotes: 3