0

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.

4

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

:%s/\/path\/name/\/new\/path/g

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:

:%s!/path/name!/new/path!g
| improve this answer | |

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.