Reputation: 2755
I am using command :%s/foo/bar/g | wq
to find and replace using vim. It works fine if pattern is available but if pattern isn't available it Error detected while processing command line:
E486: Pattern not found: foo
How can I forcefully exit even if pattern isn't found? I tried wq!
in above command but didn't help
Upvotes: 1
Views: 1102
Reputation: 69
Every time I tried to exit with :q it gave me an error message "E486: Pattern not found:..."
If I press ":" it appears "?" and instead of :q appeared ?q and gave me the error message: "E486: Pattern not found:..."
Cause? Instead of the US keyboard, I had set the Romanian (Standard) keyboard. And instead of ":" type "ș" (special Romanian character). I set back to US keyboard and everything was solved.
Upvotes: 0
Reputation: 3875
The problem is with substitute
issuing the error. You can set the flag e
:%s/foo/bar/ge | wq
which should prevent the "No match" error from breaking a mapping or commands.
Upvotes: 3