Article 6KQRV vi macro wisdom

vi macro wisdom

by
BenCollver
from LinuxQuestions.org on (#6KQRV)
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^MWhen 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!
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments