[comp.sys.ibm.pc.misc] edit multiple files in vi?

Dan_Bloch@TRANSARC.COM (09/21/90)

A few additions to the recent discussion on editing multiple files
in vi:

 - You don't need to specify the files you're editing on the command
   line.  The :n command takes arguments.  Also, see next item.

 - By default when you say :e (or :n or :n #, or control-^ or ...), vi
   tells you, "No write since last change, :e! to overwrite" or some
   such, and you have to :w to save changes.  If you :set autowrite, vi
   automatically updates the files on :tag, :n, and :rew commands (not :e),
   and you really can go back and forth between files with a keystroke.
   One caveat:  autowrite also saves changes if you do a :sh or control-Z.

 - Much as I like vi, you can't easily move around among more than two
   files.  The two best ways I know are putting them all on the command
   line, going through them with :n, and cycling or starting again at
   the first one with :rew, OR (what I usually do) remembering one file
   throughout the session, and frequently changing the alternate file.

 - "Cutting and pasting" between files is almost as easy as within a
   single file; you just have to use the named buffers for y and d
   commands.  That is, yy will be forgotten when you change files, but
   "ayy will still be known.  [Hot tip:  "Ayy appends to the buffer
   instead of replacing it.]

One last note:

wyle@inf.ethz.ch (Mitchell Wyle) writes:

> ... but I have not yet become so adept at vi that I use this way to yank,
> cut, and paste between different files without leaving vi.  I suppose
> that most of us receive poor training at the outset and fall into bad
> habits.  The vi books all suck in how they teach you to use these
> features which is one reason I am writing a better one.

IMHO, A Guide to vi: Visual Editing on the UNIX System, by Dan Sonnenschein,
Prentice-Hall, 1987, ISBN 0-13-371311-3 025 is just about the best book on
vi imaginable.  Chapter 11 is "Cut and Paste Between Files."

Dan Bloch
dan@transarc.com

Dan_Bloch@TRANSARC.COM (09/21/90)

Oops, wrong bboard.  Sorry.

Dan