Reputation: 409
I am trying to run this command in vi
:s/href="\//href="http:\/\/website.com\/folder\/subfolder\//g
but got this error E486: Pattern not found: href="\/
What am i doing wrong?
Upvotes: 2
Views: 1795
Reputation: 10074
On another note. That substition worked for me. Just copied and pasted. Are you on the same line that you are trying to perform the substitution on? the 'g' is meant globally on the line you are on. If you need to perform the search and replace on the file the use :%s/
Upvotes: 0
Reputation: 619
becouse there are many '/' chars, try use another delimiter, ex ',':
:s,some/pattern/with/slashes,new/string,g
Upvotes: 1
Reputation: 12206
That error means pretty much what it says. vi didn't find any pattern href="/
(ignoring escapes) in your file.
Sometimes it's easier to use something besides /
for the search delimiter if your search has a lot of slashes, so you don't need to escape them all. Try replacing the /
delimiter with #
instead, like this:
s#href="/#href="http://website.com/folder/subfolder/#g
Then maybe you can more easily see what's wrong with your pattern:
Upvotes: 2