I'm trying to replace this text in VIM

Actual Path /home/omipenguin/Servers\ Information/systemscript.sh/sysinfo.txt

with this new path


I tried

%s/\/home\/omipenguin\/Servers\ Information\/systemscript.sh\/sysinfo.txt//home/sysinfo/g

but VIM gives me Pattern not Found. What is wrong?


The forward slash / is used by vim as the default pattern separator: it separates the pattern from the substitution you want to make, so vim misconstrued the slashes in your path. You can specify another separator, like so:

%s!/home/omipenguin/Servers\\ Information/systemscript.sh/sysinfo.txt!/home/sysinfo!g

Note how you also need to escape the backslash \ because of its special meaning in regular expressions.

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.