Omit ‘Pattern not found’ error message in Vim script

You can either use :silent or :silent! as a prefix to any command or you can add the ‘e’ option to the substitute, which is often easier.

:%s/x/y/ge
:silent! %s/x/y/g
:silent %s/x/y/g

For more information, see

:help :silent
:help :s_flags

The information on the e flag is a few paragraphs down from the :s_flags help.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)