emacs Basic Keybindings Region - Cut, Copy, Paste


Example

  • Set mark in cursor location:

    C-space or C-@

  • Kill region (Cut):

    C-w

  • Copy region to kill ring:

    M-w or Esc-w

  • Yank (Paste) most recently killed:

    C-y

  • Yank (Paste) next last killed:

    M-y or Esc-y

Kill

killis the command used by Emacs for the deletion of text. The kill command is analogous to the cut command in Windows. Various commands exist that 'kills' one word (M-d), the rest of the line (C-k), or larger text blocks. The deleted text is added to the kill-ring, from which it can later be yanked.

Select and cut (kill)

Killing and yanking Similar to the select-and-cut feature in Windows, here we have C-spc. The key binding C-spc will start the selection, the user can move the mark with the help of arrow keys or other command to make a selection. Once selection is complete - push the C-w to kill the selected text

Some basic commands which can be used as quick reference for kill command (taken from Emacs tutorial)

    M-DEL       Kill the word immediately before the cursor
    M-d         Kill the next word after the cursor

    C-k         Kill from the cursor position to end of line
    M-k         Kill to the end of the current sentence

Yank

yankdescribes the insertion of previously deleted text, e.g. using C-y which yanks the most recently killed text. Yank command is analogous to the paste command in Windows.

Yank text killed previously

We know that the kill command adds the text killed to a kill-ring. To retrieve the deleted text from the kill-ring use M-y command repeatedly until the desired text is yanked.

(Note: For the M-y key to work the previous command should be a YANK otherwise it wouldn't work)