vim 在宏中替换失败后替换
vim replace after failed replace in macro
我在宏中有大量的查找和替换序列
:let@m=':%s/√/\sqrt/g
:%s/∫/\int/g
:%s/∑/\sum/g
:%s/∏/\prod/g
:%s/⋃/\bigcup/g
:%s/⋂/\bigcap/g
:%s/∪/\cup/g
:%s/∩/\cap/g
:%s/∂/\partial/g
:%s/–/\--/g
:%s/—/\---/g
:%s/•/\bullet/g
:%s/·/\cdot/g
:%s/◦/\circ/g
:%s/±/\pm/g
:%s/∓/\mp/g
<more stuff/>
'
如果这些查找和替换中的任何一个失败(例如,如果文件中没有 ∫),后续的将不会得到 运行。我怎样才能让 :%s///g
安静且非破坏性地失败?
来自:help :s_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.
所以:
%s/√/\sqrt/ge
%s/∫/\int/ge
…
我在宏中有大量的查找和替换序列
:let@m=':%s/√/\sqrt/g
:%s/∫/\int/g
:%s/∑/\sum/g
:%s/∏/\prod/g
:%s/⋃/\bigcup/g
:%s/⋂/\bigcap/g
:%s/∪/\cup/g
:%s/∩/\cap/g
:%s/∂/\partial/g
:%s/–/\--/g
:%s/—/\---/g
:%s/•/\bullet/g
:%s/·/\cdot/g
:%s/◦/\circ/g
:%s/±/\pm/g
:%s/∓/\mp/g
<more stuff/>
'
如果这些查找和替换中的任何一个失败(例如,如果文件中没有 ∫),后续的将不会得到 运行。我怎样才能让 :%s///g
安静且非破坏性地失败?
来自:help :s_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.
所以:
%s/√/\sqrt/ge
%s/∫/\int/ge
…