8.2. Multiwindow Editing

Perhaps the single most important feature that the clones offer over standard vi is the ability to edit files in multiple "windows." This makes it possible to easily work on more than one file at the same time, and to "cut and paste" text from one file to another via yanking and putting.[5]

[5] In the clones, you need not split the screen to yank and put between files; only the original vi discards the cut buffers when switching between files.

There are two fundamental concepts underlying each editor's multiwindow implementation, buffers and windows.

A buffer holds text to be edited. The text may come from a file, or it may be brand new text to eventually be written to a file. Any given file has only one buffer associated with it.

A window provides a view into a buffer, allowing you to see and modify the text in the buffer. There may be multiple windows associated with the same buffer. Changes made to the buffer in one window are reflected in any other windows open on the same buffer. A buffer may also have no windows associated with it. In this case, you can't do a whole lot with the buffer, although you can open a window on it later. Closing the last window open on a buffer effectively "hides" the file. If the buffer has been modified but not written to disk, the editor may or may not let you close the last window that's open on it.

When you create a new window, the editor splits the current screen. For most of the editors, you create a new window ...

Get Learning the vi Editor, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.