yank(2)yank - Paste (copy) kill buffer contents into buffer
n yank (C-y)
When a non negative argument is supplied to yank, the command copies the contents of the kill buffer n times into the current buffer at the current cursor position. This does not clear the kill buffer, and therefore may be used to make multiple copies of a section of text. On windowing systems which support clipboards, such as windows and X-terms, MicroEmacs will also cut to and paste from the global clipboard.
If yank is IMMEDIATELY followed by a reyank(2) then the yanked text is replaced by text of the next entry in the kill ring. (another reyank replaces the text with the previous reyank text and so on).
If an negative argument is given, yank removes the last 0-n items from the kill ring unless n is -98 or less.
When n is -98 or -99 yank checks for and gets the current global clipboard text regardless of whether MicroEmacs is currently running a macro, this can be useful for macros that need to interact with the system clipboard. If a system clipboard text is available it is inserted into the kill buffer and not inserted into the current buffer, if n is -99 the text is inserted as a UTF8 encoded string rather than converted to the current MicroEmacs charset.
When n is -100 the last search string match is inserted/yanked into the current buffer instead. If n is -101 then the matches first regex group is inserted, -102 the 2nd group etc., see help on @s0(4) for more information about search groups. This numerical interface can be used to avoid the 2KB variable text limit imposed on all MicroEmacs variables when a macro needs to insert or copy these value. The text of the match or search group is not inserted into the kill buffer.
Text is inserted into the kill buffer by one of the following commands:-
backward-kill-word(2), copy-region(2), forward-kill-word(2), kill-line(2), kill-paragraph(2), kill-region(2), forward-delete-char(2), backward-delete-char(2).
All the above commands (except copy-region) cut text out of the buffer, the last two character delete commands require the presence of a numeric argument to add the deleted text to the kill buffer. If any of these commands are executed immediately after any other (including itself) or the @cl(4) variable is set to one of these command, the new kill text is appended to the last kill buffer text.
Windowing systems such as X-Windows and Microsoft Windows utilize a global windowing kill buffer allowing data to be moved between windowing applications (cut buffer and clipboard, respectively). Within these environments MicroEmacs automatically interacts with the windowing systems kill buffer, the last MicroEmacs kill buffer entry is immediately available for a paste operation into another application (regardless of how it was inserted into the kill buffer). Conversely, data placed in the windowing kill buffer is available to MicroEmacs, via yank, until a new item has been inserted into the kill buffer (the data may still be available via reyank(2)).
The following example is a basic macro code implementation of the transpose-lines(2) command,
beginning-of-line kill-line forward-line yank -1 yank backward-line
Note that similar to transpose-lines it does not leave the moved line in the kill buffer, effectively tidying up after itself.
backward-delete-char(2), backward-kill-word(2), copy-region(2), forward-delete-char(2), forward-kill-word(2), kill-line(2), kill-paragraph(2), kill-region(2), reyank(2), yank-rectangle(2), @y(4), @cc(4), @s0(4).
(c) Copyright JASSPA 2025
Last Modified: 2025/06/21
Generated On: 2025/09/29