If I have this directory: /home/abc/def/apples/

and I want to replace it with this directory: /home/nfl/nfl/nba/ in vim,

what is the syntax? I tried using %s/a/b/g but this command fails.

1 Answer 1


You can escape the / with a backslash (\):


This is usually okay if you have just one or two /s, but it quickly becomes very unwieldy. A better option is to use a different delimiter:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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