Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to replace this text in VIM

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

with this new path

/home/sysinfo

I tried

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

but VIM gives me Pattern not Found. Please advise, what is wrong?

share|improve this question
add comment

1 Answer 1

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.