What does "rotate the kill ring" mean?
M-y undoes the last yank, rotates the lists of all kept kill strings, and yank the new top of the list. Try this example:
- type the 5 characters
a b c
(no newline) - position the cursor (with C-b) in front of the
c
and type C-k to kill thec
onto the top of the kill ring. - Position the cursor 2 chars to the left and type C-k to kill the
b
, - and again to the start of the line and type C-k to kill the
a
.
Now type C-y and you yank the a
from the top of the list.
Type C-y again, you just get another a
, but if you immediately type M-y the a
is removed and replaced by b
.
If you now type another C-y you get b
, not a
, because the kill-ring has been rotated. Similarly, a M-y will replace the b
by a c
.
When you type the sequence C-y followed by lots of M-y you get each of the kill-ring strings, one by one.
I’m not an Emacs user but for the last month I’ve being experimenting with Emacs mode in Readline as an alternative to Vi mode.
Every time you kill (delete) text, it’s removed from the buffer and added to the kill ring. When you yank (paste) the text with C-Y
, the most recently killed text is printed to the cursor position.
If you immediately follow this with M-Y
(Meta key can usually be obtained by pressing Alt-Y or Esc followed by Y), the text printed by the C-Y
yank is replaced with the second most recently killed text. If you follow that with another M-Y
, the pasted text is replaced with the third most recently killed piece of text, and so on. Each successive press of M-Y
changes the pasted text to that of the next “kill” in the kill-ring until you reach the end of the kill ring – where it rotates back to the most recent kill.