Search code examples
vimreplacetextedit

Replacing/substituting text with a forward slash in VIM


I'm trying to replace the first part of a pathing in a long file I have.

Currently, the part I want to replace reads

CurrentDir

And I want to replace it with

NewPath/ToDirectory

The problem is I cannot find how to format the replace to incorperate the additional /ToDirectory part of it. I would greatly appreciate any help on this matter


Solution

  • If the problem is escaping the forward slash, then simply use a different separator character:

    :%s,CurrentDir,NewPath/ToDirectory,g
    

    This even works in any version of sed(1).