I have a big sequence of find and replace's in a 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/>
'
If any one of these find and replace's fails (for instance if there is no ∫ in the file), the subsequent ones don't get run. How can I make :%s///g fail quietly and nondestructively?
From :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.
so:
%s/√/\\sqrt/ge
%s/∫/\\int/ge
…
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With