2

I was editing a file and found accidentally that I somehow escaped all the forward slashes in a path I was replacing in text. And that is something very useful!

For instance, to do this replacement correctly I should escape the second path:

:%s/mvn//opt/maven/bin/mvn/g

I did that somehow with an accidental keystroke! But which one? :-(

Thank you.

9

You don't need to escape them: you could use a different separator for the search pattern and the replace part:

%s;mvn;/opt/maven/bin/mvn;g

But, if you really want to escape them, you can use a backslash (\):

%s/mvn/\/opt\/maven\/bin\/mvn/g

(much harder to read, IMO)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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