10 Yanking Text Back

Whenever you cut text out of a buffer with a kill command in GNU Emacs, you can bring it back with a yank command. The text that is cut out of the buffer is put in the kill ring and the yank commands insert the appropriate contents of the kill ring back into a buffer (not necessarily the original buffer).

A simple C-y (yank) command inserts the first item from the kill ring into the current buffer. If the C-y command is followed immediately by M-y, the first element is replaced by the second element. Successive M-y commands replace the second element with the third, fourth, or fifth element, and so on. When the last element in the kill ring is reached, it is replaced by the first element and the cycle is repeated. (Thus the kill ring is called a “ring” rather than just a “list”. However, the actual data structure that holds the text is a list. See Handling the Kill Ring, for the details of how the list is handled as a ring.)