Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Omit 'Pattern not found' error message in Vim script

Tags:

vim

vi

I added a function in my .vimrc that's just few search and replace commands. However if one of the patterns is not found I get an error message that I need to enter through. How can I suppress this?

like image 311
nearly_lunchtime Avatar asked Jun 25 '09 11:06

nearly_lunchtime


1 Answers

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.

like image 159
DrAl Avatar answered Oct 04 '22 13:10

DrAl