Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!linac!midway!gargoyle!chinet!les From: les@chinet.chi.il.us (Leslie Mikesell) Newsgroups: comp.editors Subject: Re: Vi/Ex: Editor command line editor? Message-ID: <1991Mar01.171956.6466@chinet.chi.il.us> Date: 1 Mar 91 17:19:56 GMT References: <5104@lure.latrobe.edu.au> <2608@virgo.csl.sony.co.jp> Organization: Chinet - Chicago Public Access UNIX Lines: 43 In article <2608@virgo.csl.sony.co.jp> kono@csl.sony.co.jp writes: >> :.,.+3s/some long expression/another long expression/g... >> OOPS! I mistyped something. >>Command line editing for ex? >In vi, my friends gave me this. (Yes, I prefer vi, even in non crt terminal..) >map ^X "zdd@z >map! ^X "zdd@z >Of course ^X means real control-X. Input your complex :command, and >^X will delete it and execute it. Using this macro without understanding it would obscure the real value of the technique, so let me elaborate on what this does and why it is a good idea to use it for anything complicated. The idea here is to build the complicated command in the edit buffer, delete it to a named register, then execute the register. Aside from the advantage of being able to use all normal edit command while typing the entry, you can examine the results after execution and if you didn't get it quite right, simply 'u' to undo the command, yank the command back to the edit buffer and try again. The vi commands to do this are simple enough that it's hardly worth mapping: (I'll use register a here - any letter will do) "add (delete line to register) @a (execute register) u (didn't work, undo it *note - must be NEXT edit command) "aP (put register a back into edit buffer) Knowing this makes life much easier for those of us who never get it right on the first try. Note that you have to include the ":" to begin an ex mode command and double any ^V quoting needed (once to get it into the edit buffer and another copy for when the command is evaluated. Note for anyone developing a new editor or working on new features for old ones. Being able to yank the last (or last n) command(s) into the edit buffer so that you could start this cycle after the undo is right at the top of my wish list. Les Mikesell les@chinet.chi.il