如果我做类似的事情:
:%s/aaa/bbb/ | %s/111/222/
并且第一次搜索和替换没有找到任何匹配项,第二次搜索和替换将不会执行。有没有办法告诉 vim 即使命令“失败”也继续执行?
Try
:%s/aaa/bbb/e | %s/111/222/e
and read
:help :s_flags https://vimhelp.appspot.com/change.txt.html#%3As_flags
特别是下面的条目[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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)