I am trying to replace multiple forward slashes "//" with a single slash "/".
How would you do that?
Also, How would you replace "asd/qwe/zxc" with "fgh/vbn"?
I was able to do this half way using below. But how do I use forward slash in the search string or the replace string.
:%s/asd.qwe.zxc/fgh/g
Either escape it or use different delimiters.
:s/\/\//\//g
:s#//#/#g
I prefer the latter.
Missed the second part:
:s/asd\/qwe\/zxc/fgh\/vbn/g
:s@asd/qwe/zxc@fgh/vbn@g
You can pick any delimiter that you want in the same manner that you could in ed
or sed
.
You can try using:
:%s/\/\//\//g
to replace all double slashes with single slashes (though I imagine a guru will show a much cooler way shortly :) ). The general idea is that you need to escape the slashes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With