Book HomeLearning the vi EditorSearch this book

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.[41]

[41]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 which shows another view on the file you're currently editing. You then switch to the window where you wish to edit the next file, and instruct the editor to start editing the file there. Each editor provides vi and ex commands to switch back and forth between windows, as well as the ability to change the window size, and hide and restore windows.

In each editor's chapter, we show a sample split screen (editing the same two files), and describe how to split the screen and move between windows.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.