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.

Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271

1 Answers1

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
Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271