[comp.editors] Vi/Ex: Editor command line editor?

ECSGRT@lure.latrobe.edu.au (GEOFFREY TOBIN, ELECTRONIC ENGINEERING) (02/27/91)

In article <4748@male.EBay.Sun.COM, carl@mugwump.UK.Sun.COM
(Carl Johnson - Sun EHQ - MIS) writes:

>prompt> vi afile.c
>editeditedit
>:e completelynewfile.c
>  error msg saying I haven't written my changes  (query 1)
>	I dont care so..
>:e! some_amazing_vi_command to reference the last file  (query 2)

Carl's questions were answered, but how about this:

  :.,.+3s/some long expression/another long expression/g...
    OOPS!  I mistyped something.
  u
  :BORING REPETITION WITH A ONE-CHARACTER CORRECTION
    OOPS!  I miscued again.  All this work for a once-only!
  :AND SO ON

Command line editing for ex?

GT

hansm@cs.kun.nl (Hans Mulder) (02/27/91)

In article <5104@lure.latrobe.edu.au> ECSGRT@lure.latrobe.edu.au (GEOFFREY TOBIN, ELECTRONIC ENGINEERING) writes:
>  :.,.+3s/some long expression/another long expression/g...
>    OOPS!  I mistyped something.
>  u
>  :BORING REPETITION WITH A ONE-CHARACTER CORRECTION
>    OOPS!  I miscued again.  All this work for a once-only!
>  :AND SO ON
>
>Command line editing for ex?

Would be a great idea.  Definitely.

If you know in advance you are going to mistype that long expression,
you can fake it: you enter the line into your main edit buffer, and
execute it by saying "yY@y (and then you undo it, repair it, etc.).

But it would be much nicer if you could access previous : / and ! commands
with some sort of Korn shell style history mechanism.

>GT

Hans Mulder	hansm@cs.kun.nl

peter@ficc.ferranti.com (Peter da Silva) (02/27/91)

In article <5104@lure.latrobe.edu.au> ECSGRT@lure.latrobe.edu.au (GEOFFREY TOBIN, ELECTRONIC ENGINEERING) writes:
> Command line editing for ex?

The "se" editor by a number of people (currently Arnold Robbins at emory)
allows this. It's a sort of semi-screen-oriented "ex".
-- 
Peter da Silva.  `-_-'  peter@ferranti.com
+1 713 274 5180.  'U`  "Have you hugged your wolf today?"

kono@csl.sony.co.jp (Shinji Kono) (03/01/91)

In article <5104@lure.latrobe.edu.au>  
	, ECSGRT@lure.latrobe.edu.au (GEOFFREY TOBIN, ELECTRONIC ENGINEERING) 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.
--------
Shinji Kono, E-Mail: kono@csl.sony.co.jp, nifty: MAF00476
$@2OLn??<#(J Sony Computer Science Laboratory, Inc.

les@chinet.chi.il.us (Leslie Mikesell) (03/02/91)

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