I am trying a simple find and replace function in VI Editor to change a profile path but the / is getting in my way and I need a simple and clever solution.

I tried using:

%s/profile: "/fldr0/local/fldr/fldr1/profile/production/production.auto.profile"/profile: "/fldr0/local/fldr/fldr1/profile/development/development.auto.profile"/g

And got E488: Trailing characters.

I know it has to do with the slashes but not sure what a good workaround would be since I thought the "" would take care of it but they didn't - any help appreciated! Read all the other threads and couldn't come up with a solution probably due to lack of brain power on my part

1 Answer 1


You want to change instances of

profile: /fldr0/local/fldr/fldr1/profile/production/production.auto.profile


profile: /fldr0/local/fldr/fldr1/profile/development/development.auto.profile

One way is to use a different delimiter than / for the :substitute command, i.e.:

%s;profile: /fldr0/local/fldr/fldr1/profile/production/production.auto.profile;profile: /fldr0/local/fldr/fldr1/profile/development/development.auto.profile;g

However, it can also be simplified quite alot:


In the above regular expression, profile:.* will match the first part in a greedy manner, up until the first production. \zs sets the start of the matched part, which means everything before this is ignored for the replacement. Finally, the production/production is the only part of the string we want to change, and we escape the / with a backslash, i.e. \/.

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.