0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! The variant with script is exactly what I need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.