Next: Searching and Replacing
Up: Editing files with Emacs
Previous: The Meta Key
Emacs, like any good editor, allows you to cut and paste blocks of
text. In order to do this, you need a way to define the start and end
of the block. In Emacs, you do this by setting two locations in the
buffer, known as mark and
point . To set the mark, go to the place you
want your block to begin and type C-SPC (``SPC'' means
, of course). You should see the message ``Mark set''
appear in the minibuffer. The mark has now
been set at that place. There will be no special highlighting
indicating that fact, but you know where you put it, and that's all
that matters.
What about point? Well, it turns out that you've been setting
point every time you move the cursor, because ``point'' just refers to
your current location in the buffer. In formal terms, point is the
spot where text would be inserted if you were to type something. By
setting the mark, and then moving to the end of the block of text, you
have actually defined a block of text. This block is known as the
region . The region always means the area
between mark and point.
Merely defining the region does not make it available for pasting.
You have to tell Emacs to copy it in order to be able to paste it. To
copy the region, make sure that mark and point are set correctly, and
type M-w. It has now been recorded by Emacs. In order to paste
it somewhere else, just go there and type C-y. This is known as
yanking the text into the buffer.
If you want to actually move the text of the region to somewhere else,
type C-w instead of M-w. This will
kill the region--all the text inside it will
disappear. In fact, it has been saved in the same way as if you had
used M-w. You can yank it back out with C-y, as always.
The place Emacs saves all this text is known as the kill-ring.
Some editors call it the ``clipboard'' or the ``paste buffer''.
There's another way to do cutting and pasting: whenever you
use C-k to kill to the end of a line, the killed text is saved
in the kill-ring. If you kill more than one line in a row, they are
all saved in the kill-ring together, so that the next yank will paste
in all the lines at once. Because of this feature, it is often faster
to use repeated C-k's to kill some text than it is to explicitly
set mark and point and use C-w. However, either way will work.
It's really a matter of personal preference how you do it.
Next: Searching and Replacing
Up: Editing files with Emacs
Previous: The Meta Key
Converted on:
Mon Apr 1 08:59:56 EST 1996
|