Reputation: 5335
I need to replace multiple patterns to get TeX notation in reports. I use vim for creating reports. There are many patterns to replace (about 100), for example,
%s/U_CC/$U_{CC}$/
%s/tplh/$t_{plh}$/
%s/U\(.*\)_\(.*\)V||\(.*\)$/$U_{\1}$|V|\3|$U_{CC}=\2 V$/
etc. Is there a way to speed up this work in vim, for example, by using some file with patterns and replacing strings?
Upvotes: 0
Views: 113
Reputation: 32926
You can define a function that chains all the substitutes (preceded with a :silent!
to neutralize errors)., or you can put all your substitutions in a vim script (that you could put anywhere, or only in ~/.vim/macros/
under ~/.vim/
), and source that script with :so ~/.vim/macros/fix-my-report.vim
for instance.
Upvotes: 1