Suppress errors when substituting in vim
The substitute
(or s
) command in vim throws an error the search pattern is not found.
:substitute/banana/apple
E486: Pattern not found: banana
This error can be suppressed with the e flag at the end of the statement.
:substitute/banana/apple/e
When operating in just one file or on just one line the error is a minor annoyance but when combining the substitute command with :argdo
you receive an error for every file in the args list that does not contain the pattern in question.
A typical argdo command would look like this.
:argdo s/banana/apple/gec
The flags are:
g - global
e - suppress errors
c - confirm
Tweet