12.2 Yanking
Yanking means reinserting text previously killed. The usual way to move or copy text is to kill it and then yank it elsewhere.
C-y
Yank the last kill into the buffer, at point (yank
).
M-y
Replace the text just yanked with an earlier batch of killed text (yank-pop
). See Earlier Kills.
C-M-w
Cause the following command, if it is a kill command, to append to the previous kill (append-next-kill
). See Appending Kills.
The basic yanking command is C-y
(yank
). It inserts the most recent kill, leaving the cursor at the end of the inserted text. It also sets the mark at the beginning of the inserted text, without activating the mark; this lets you jump easily to that position, if you wish, with C-u C-SPC
(see Mark Ring).
With a plain prefix argument (C-u C-y
), the command instead leaves the cursor in front of the inserted text, and sets the mark at the end. Using any other prefix argument specifies an earlier kill; e.g., C-u 4 C-y
reinserts the fourth most recent kill. See Earlier Kills.
On graphical displays, C-y
first checks if another application has placed any text in the system clipboard more recently than the last Emacs kill. If so, it inserts the clipboard’s text instead. Thus, Emacs effectively treats “cut" or “copy" clipboard operations performed in other applications like Emacs kills, except that they are not recorded in the kill ring. See Cut and Paste, for details.
• Kill Ring | Where killed text is stored. | |
• Earlier Kills | Yanking something killed some time ago. | |
• Appending Kills | Several kills in a row all yank together. |