home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / editors / 2078 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  2.2 KB

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