LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   vi macro wisdom (https://www.linuxquestions.org/questions/linux-software-2/vi-macro-wisdom-4175735496/)

BenCollver 03-30-2024 11:23 AM

vi macro wisdom
 
I am using ex-vi on Slackware (not vim).

I wrote a macro in ~/.exrc to do multiple search & replace commands. Each command is followed by the ^M character (AKA CR). The macro works great if the search matches something. The first search that fails to match something causes the macro to stop running, and it skips the remaining commands.

Example:

Code:

map V :%s:foo:bar:g^M:%s:bletch:frobnotz:g^M:%s:zorkmid:aromdee:g^M
When i press "V", it will search for foo.
If it fails to find foo, then it will quit.
If it finds foo, then it will replace it with bar, and then search for bletch.
And so forth.

Any ideas how to execute the complete macro even if the first command fails to find a match?

Thanks!


All times are GMT -5. The time now is 03:39 AM.