home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!introl.introl.com!ferret!stv
- From: stv@ferret.uucp (Steve Manning)
- Newsgroups: comp.editors
- Subject: Re: Command line editing in vi
- Message-ID: <1992Aug27.052100.1716@ferret.uucp>
- Date: 27 Aug 92 05:21:00 GMT
- Article-I.D.: ferret.1992Aug27.052100.1716
- References: <1992Aug12.021145.5902@nuscc.nus.sg>
- Organization: SSR Manning at home
- Lines: 39
-
- In article <1992Aug12.021145.5902@nuscc.nus.sg> ccechk@nuscc.nus.sg (Heng Kek) writes:
- > How may I 'recall' the last cmd I entered in vi in such
- >a way that I can edit that command and execute it? Something like
- >the history command editing in tcsh.
- >
- >This feature is real useful in situations when I enter a mistyped
- >command and want to reenter the corrected one. Imagine entering
- >something like ":'a,$s/\([a-z]*\).*\([0-9]\) *[^ ]*)/\2,\1==/" only
- >to find that you've missed a '('. It's not fun to retype the whole
- >thing. :)
-
- Whenever I find that I'm going to be constructing a long pattern
- such as the one you list, I will take advantage of vi's ability to
- execute the contents of a named buffer as a macro. Typing the
- AT-symbol ('@') followed by a letter (in command mode, of course)
- will do this. Of course, this does require you to take steps before-
- hand to do it and so is not "history command editing".
-
- Simply type the command directly into the file on a line of its
- own, delete the line into a named buffer ("add), and then execute
- the contents of that buffer (@a). If there are any problems, simply
- undo (u), replace the buffer into the file ("ap), edit, and repeat!
-
- BTW, I've worked with older, buggier versions of vi and I've had
- them drop the contents of the buffer I try to use if there are
- certain types of errors in the command therein. So I've gotten in
- the habit of yanking the command into two or more buffers before
- I try to execute it, just in case.
-
- Of course, you could also save the command in a file of it's own
- and execute the file with the :source command. You shouldn't have
- to worry about vi going out and erasing the contents of your command
- file :-).
-
- Enjoy!
- --
- Steve Manning stv%ferret@introl.introl.com stv@ferret.uucp
- Milwaukee, WI ...!introl!ferret!stv etc., etc., etc.
- "...but you're wrong, Steve. You see, it's only Solitaire" I.A.
-