Multiple search and replace in one line

If I do something like:

:% s / aaa / bbb / | % S / 111/222 /,

and the first search and replacement will not find matches, the second search and replacement will not be performed. Is there any way to tell vim to continue even when the command failed?

+49
vim
Jan 19 2018-11-11T00:
source share
1 answer

Try

:%s/aaa/bbb/e | %s/111/222/e 

and read

 :help :s_flags 

especially the entry in [e] :

  When the search pattern fails, do not issue an error message and, in particular, continue in maps as if no error occurred. This is most useful to prevent the "No match" error from breaking a mapping. Vim does not suppress the following error messages, however: Regular expressions can't be delimited by letters \ should be followed by /, ? or & No previous substitute regular expression Trailing characters Interrupted 
+77
Jan 19 '11 at 15:38
source share



All Articles