Most Emacs commands operate on the region defined by the point, which
is the location of the cursor at any given time, and the mark, which
is set with the command C-space
. To copy or cut a region of text, move
the cursor to the start of the text area you are interested in and
type C-space
. You will see "Mark set" in the echo area. Now move the
cursor to the end of the text region (which moves the point) and type
M-w
for copy or C-w
for cut (both called killing text). The text you
copy or cut is stored by Emacs in the kill-ring, which is a circular
buffer that stores the text snippets you kill in a last-in-first-out
order. To paste the most recently stored text, move the cursor to
where the text should be inserted, and type C-y
. The "y" stands for
yank, what you'll see paste referred to in the Emacs help
documentation (remember Emacs pre-dated modern windowing systems and
other full-screen editors, so the terms cut and paste were not in use
yet). After a yank (C-y
) command, you can replace the inserted text
with earlier kills in turn by typing M-y
one or more times. Each time
you press M-y
the next block of killed text is popped off of the kill
ring and inserted into your buffer, replacing the last insert at the
same time.
Here are the commands we discussed above, and a few other useful ones:
C-space | Set the mark |
C-w | Cut (kill) |
M-w | Copy (kill) |
C-y | Paste (yank) |
M-y | Paste (yank) next saved selection |
C-x h | Set point to start of buffer and mark to end of buffer (select the entire buffer) |
C-x C-x | Go back to the last mark that was set |