4.3 Making Use of Buffers
You have seen that while you are editing, your last deletion
(
The last nine deletions are stored by vi
in numbered buffers. You can access any of these numbered buffers
to restore any (or all) of the last nine deletions.
(Small deletions, of only parts of lines, are not saved in
numbered buffers, however. These deletions can only be recovered
by using the vi also allows you to place yanks (copied text) in buffers identified by letters. You can fill up to 26 (a-z) buffers with yanked text and restore that text with a put command at any time in your editing session. 4.3.1 Recovering DeletionsBeing able to delete large blocks of text at a single bound is all very well and good, but what if you mistakenly delete 53 lines that you need? There is a way to recover any of your past nine deletions, for they are saved in numbered buffers. The last delete is saved in buffer 1, the second-to-last in buffer 2, and so on.
To recover a deletion, type "2p The deletion in buffer 2 is placed after the cursor.
If you're not sure which buffer contains the deletion you want to
restore, you don't have to keep typing
"1pu.u.u etc. to put the contents of each succeeding buffer in the file
one after the other.
Each time you type 4.3.2 Yanking to Named Buffers
You have seen that you must put (
To yank into a named buffer, precede the
yank command with a double quote (
After loading the named buffers and moving to the new position, use
There is no way to put part of a buffer into the text -- it is all or nothing. In the next chapter, you'll learn to edit multiple files. Once you know how to travel between files without leaving vi , you can use named buffers to selectively transfer text between files. You can also delete text into named buffers using much the same procedure:
If you specify a buffer name with a capital letter, your yanked or deleted text will be appended to the current contents of that buffer. This allows you to be selective in what you move or copy. For example:
|
|