4.4 Cutting, copying and pasting
In Figure 4.5, the kill ring contains three items; the words factorial
, function
and macro
respectively.
Figure 4.5 Contents of the kill ring.
First, the word factorial
was cut from the current buffer. This removed it from the buffer. Next, the word function
was copied, which left it in the buffer but added a copy of it to the kill ring, and then word macro
was cut.
The kill ring rotates. (This is why it is known as a ring.) Every time a new item is added to it, the others are shunted round.
Figure 4.6 Pasting from the kill ring.
Whenever you perform a paste (with C-y
), the current item in the kill ring -- the word macro
in this example -- is copied back into the buffer wherever the cursor currently is. The pasted item is not removed from the kill ring.
What you have seen so far is exactly the same as the clipboard in any other Windows text editor. It is true that all three items have been kept in the kill ring, but they are of no use if you cannot get at them.
The command which allows you to do this is Esc y
. This rotates the kill ring in the opposite direction -- thus making the previous item the current one -- and pastes it into the buffer in place of the item just pasted. In the diagram on the left, the word macro
would be replaced with the word function
.
Figure 4.7 Pasting function
from the kill ring.
You can use Esc y
as many times as you like. For instance, if you wanted to paste the word factorial
in the document, pressing Esc y
would replace the word function
with the word factorial
.
Figure 4.8 Pasting factorial
from the kill ring.
If you pressed Esc y
a third time, the kill ring would have rotated completely, and macro
would have been the current item once again.
Note: You can never use Esc y
without having used C-y
first.
Here is a summary of the way C-y
and Esc y
work:
C-y
pastes the current item in the kill ring into the buffer
Esc y
rotates the kill ring back one place, and then pastes the current item into the buffer, replacing the previously pasted item.
Generated with Harlequin WebMaker