ring}, from which it can be retrieved by @dfn{yanking} it. Some systems
use the terms ``cutting'' and ``pasting'' for these operations.
- The commonest way of moving or copying text within Emacs is to kill it
+ The most common way of moving or copying text within Emacs is to kill it
and later yank it elsewhere in one or more places. This is very safe
because Emacs remembers several recent kills, not just the last one. It
is versatile, because the many commands for killing syntactic units can
also be used for moving those units. But there are other ways of
copying text for special purposes.
+ On terminals that support multiple windows for multiple applications,
+the kill commands also provide a way to select text for other applications
+to copy, and the Emacs yank commands can access selections made by
+other programs.
+
Emacs has only one kill ring for all buffers, so you can kill text in
one buffer and yank it in another buffer.
area tells you what is happening.
The delete commands include @kbd{C-d} (@code{delete-char}) and
-@key{DEL} (@code{delete-backward-char}), which delete only one character at
-a time, and those commands that delete only spaces or newlines. Commands
-that can destroy significant amounts of nontrivial data generally kill.
-The commands' names and individual descriptions use the words @samp{kill}
-and @samp{delete} to say which they do.
+@key{DEL} (@code{delete-backward-char}), which delete only one
+character at a time, and those commands that delete only spaces or
+newlines. Commands that can destroy significant amounts of nontrivial
+data generally do a kill operation instead. The commands' names and
+individual descriptions use the words @samp{kill} and @samp{delete} to
+say which kind of operation they perform.
+
+ On window systems, the most recent kill done in Emacs is also the
+primary selection, if it is more recent than any selection you made in
+another program. This means that the paste commands of other window
+applications copy the text that you killed in Emacs.
@cindex Delete Selection mode
@cindex mode, Delete Selection
blank areas.
* Killing by Lines:: How to kill entire lines of text at one time.
* Other Kill Commands:: Commands to kill large regions of text and
- syntactic units such as words and sentences.
+ syntactic units such as words and sentences.
@end menu
+@need 1500
@node Deletion
@subsection Deletion
-@c ??? Should be backward-delete-char
@findex delete-backward-char
@findex delete-char
+ Deletion means erasing text and not saving it in the kill ring. For
+the most part, the Emacs commands that delete text are those that
+erase just one character or only whitespace.
+
@table @kbd
@item C-d
@itemx @key{Delete}
@item @key{DEL}
@itemx @key{BS}
Delete previous character (@code{delete-backward-char}). Some keyboards
-refer to this key as a ``backspace key'' and label it with a left arrow:
-@key{<-}.
+refer to this key as a ``backspace key'' and label it with a left arrow.
@item M-\
Delete spaces and tabs around point (@code{delete-horizontal-space}).
@item M-@key{SPC}
Every keyboard has a large key, labeled @key{DEL}, @key{BACKSPACE},
@key{BS} or @key{DELETE}, which is a short distance above the
@key{RET} or @key{ENTER} key and is normally used for erasing what you
-have typed. Regardless of the actual name on the key, it is
+have typed. Regardless of the actual name on the key, in Emacs it is
equivalent to @key{DEL}---or it should be.
- Many keyboards have a @key{BACKSPACE} key a short ways above
-@key{RET} or @key{ENTER}, and a @key{DELETE} key elsewhere. In that
-case, the @key{BACKSPACE} key is @key{DEL}, and the @key{DELETE} key
-is equivalent to @kbd{C-d}---or it should be.
+ Many keyboards (including standard PC keyboards) have a
+@key{BACKSPACE} key a short ways above @key{RET} or @key{ENTER}, and a
+@key{DELETE} key elsewhere. In that case, the @key{BACKSPACE} key is
+@key{DEL}, and the @key{DELETE} key is equivalent to @kbd{C-d}---or it
+should be.
-@findex delete-key-deletes-forward-mode
Why do we say ``or it should be''? When Emacs starts up using a
-window system, it determines automatically which key should be
-equivalent to @key{DEL}. So the @key{BACKSPACE} and/or @key{DELETE}
-keys will almost surely do the right things. But on text-only
-terminals, Emacs cannot tell which key is where; it has to make an
-assumption, which can be wrong.
-
- If the usual key for text erasure does not behave as @key{DEL},
-probably that means it is really a @key{BACKSPACE} key. You can use
-the command @kbd{M-x delete-key-deletes-forward-mode} to swap the
-meanings of @key{BACKSPACE} and @key{DEL}, so that the convenient key
-for deletion actually does deletion. To do this for every Emacs
-session, put the following line into your @file{.emacs} init file
-(@pxref{Init File}):
-
-@lisp
-(delete-key-deletes-forward-mode 1)
-@end lisp
-
-@noindent
-This also makes the @key{DELETE} key, if there is one, delete the
-character after the cursor.
-
-@vindex delete-key-deletes-forward
-The variable @code{delete-key-deletes-forward} is @code{t} in the mode
-where the @key{DELETE} key deletes forwards, @code{nil} if
-@key{DELETE} is equivalent to @key{DEL} and deletes backwards.
+window system, it determines automatically which key or keys should be
+equivalent to @key{DEL}. As a result, @key{BACKSPACE} and/or @key{DELETE}
+keys normally do the right things. But in some unusual cases Emacs
+gets the wrong information from the system. If these keys don't do
+what they ought to do, you need to tell Emacs which key to use for
+@key{DEL}. @xref{DEL Does Not Delete}, for how to do this.
+
+@findex normal-erase-is-backspace-mode
+ On most text-only terminals, Emacs cannot tell which keys the
+keyboard really has, so it follows a uniform plan which may or may not
+fit your keyboard. The uniform plan is that the @acronym{ASCII} @key{DEL}
+character deletes, and the @acronym{ASCII} @key{BS} (backspace) character asks
+for help (it is the same as @kbd{C-h}). If this is not right for your
+keyboard, such as if you find that the key which ought to delete backwards
+enters Help instead, see @ref{DEL Does Not Delete}.
@kindex M-\
@findex delete-horizontal-space
characters before and after point. @kbd{M-@key{SPC}}
(@code{just-one-space}) does likewise but leaves a single space after
point, regardless of the number of spaces that existed previously (even
-zero).
+if there were none before).
@kbd{C-x C-o} (@code{delete-blank-lines}) deletes all blank lines
after the current line. If the current line is blank, it deletes all
When @kbd{C-k} is given a positive argument, it kills that many lines
and the newlines that follow them (however, text on the current line
-before point is spared). With a negative argument @minus{}@var{n}, it
+before point is not killed). With a negative argument @minus{}@var{n}, it
kills @var{n} lines preceding the current line (together with the text
on the current line before point). Thus, @kbd{C-u - 2 C-k} at the front
of a line kills the two previous lines.
@findex kill-region
@kindex C-w
-@c DoubleWideCommands
@table @kbd
@item C-w
Kill region (from point to the mark) (@code{kill-region}).
@item M-k
Kill to end of sentence (@code{kill-sentence}).
@item C-M-k
-Kill sexp (@code{kill-sexp}). @xref{Lists}.
+Kill the following balanced expression (@code{kill-sexp}). @xref{Expressions}.
@item M-z @var{char}
Kill through the next occurrence of @var{char} (@code{zap-to-char}).
@end table
numeric argument acts as a repeat count. A negative argument means to
search backward and kill text before point.
- Other syntactic units can be killed: words, with @kbd{M-@key{DEL}} and
-@kbd{M-d} (@pxref{Words}); sexps, with @kbd{C-M-k} (@pxref{Lists}); and
-sentences, with @kbd{C-x @key{DEL}} and @kbd{M-k}
-(@pxref{Sentences}).@refill
+ Other syntactic units can be killed: words, with @kbd{M-@key{DEL}}
+and @kbd{M-d} (@pxref{Words}); balanced expressions, with @kbd{C-M-k}
+(@pxref{Expressions}); and sentences, with @kbd{C-x @key{DEL}} and
+@kbd{M-k} (@pxref{Sentences}).@refill
You can use kill commands in read-only buffers. They don't actually
change the buffer, and they beep to warn you of that, but they do copy
Append next kill to last batch of killed text (@code{append-next-kill}).
@end table
+ On window systems, if there is a current selection in some other
+application, and you selected it more recently than you killed any
+text in Emacs, @kbd{C-y} copies the selection instead of text
+killed within Emacs.
+
@menu
* Kill Ring:: Where killed text is stored. Basic yanking.
* Appending Kills:: Several kills in a row all yank together.
a @kbd{C-u}, precisely. Any other sort of argument, including @kbd{C-u}
and digits, specifies an earlier kill to yank (@pxref{Earlier Kills}).
+@cindex yanking and text properties
+@vindex yank-excluded-properties
+ The yank commands discard certain text properties from the text that
+is yanked, those that might lead to annoying results. For instance,
+they discard text properties that respond to the mouse or specify key
+bindings. The variable @code{yank-excluded-properties} specifies the
+properties to discard. Yanking of register contents and rectangles
+also discard these properties.
+
@kindex M-w
@findex kill-ring-save
To copy a block of text, you can use @kbd{M-w}
with point shown by @point{}. If you type @kbd{M-d M-@key{DEL} M-d
M-@key{DEL}}, killing alternately forward and backward, you end up with
@samp{a line of sample} as one entry in the kill ring, and @samp{This
-is@ @ text.} in the buffer. (Note the double space, which you can clean
-up with @kbd{M-@key{SPC}} or @kbd{M-q}.)
+is@ @ text.} in the buffer. (Note the double space between @samp{is}
+and @samp{text}, which you can clean up with @kbd{M-@key{SPC}} or
+@kbd{M-q}.)
Another way to kill the same text is to move back two words with
@kbd{M-b M-b}, then kill all four words forward with @kbd{C-u M-d}.
text in the buffer changes to match. Enough @kbd{M-y} commands can move
the pointer to any entry in the ring, so you can get any entry into the
buffer. Eventually the pointer reaches the end of the ring; the next
-@kbd{M-y} moves it to the first entry again.
+@kbd{M-y} loops back around to the first entry again.
@kbd{M-y} moves the ``last yank'' pointer around the ring, but it does
not change the order of the entries in the ring, which always runs from
yank'' pointer remains at the same place in the kill ring, so repeating
@kbd{C-y} will yank another copy of the same previous kill.
- If you know how many @kbd{M-y} commands it would take to find the text
-you want, you can yank that text in one step using @kbd{C-y} with a
-numeric argument. @kbd{C-y} with an argument restores the text the
-specified number of entries back in the kill ring. Thus, @kbd{C-u 2
-C-y} gets the next-to-the-last block of killed text. It is equivalent
-to @kbd{C-y M-y}. @kbd{C-y} with a numeric argument starts counting
-from the ``last yank'' pointer, and sets the ``last yank'' pointer to
-the entry that it yanks.
+ If you know how many @kbd{M-y} commands it would take to find the
+text you want, you can yank that text in one step using @kbd{C-y} with
+a numeric argument. @kbd{C-y} with an argument restores the text from
+the specified kill ring entry, counting back from the most recent as
+1. Thus, @kbd{C-u 2 C-y} gets the next-to-the-last block of killed
+text---it is equivalent to @kbd{C-y M-y}. @kbd{C-y} with a numeric
+argument starts counting from the ``last yank'' pointer, and sets the
+``last yank'' pointer to the entry that it yanks.
@vindex kill-ring-max
The length of the kill ring is controlled by the variable
@table @kbd
@item M-x append-to-buffer
-Append region to contents of specified buffer.
+Append region to the contents of a specified buffer.
@item M-x prepend-to-buffer
-Prepend region to contents of specified buffer.
+Prepend region to the contents of a specified buffer.
@item M-x copy-to-buffer
-Copy region into specified buffer, deleting that buffer's old contents.
+Copy region into a specified buffer, deleting that buffer's old contents.
@item M-x insert-buffer
-Insert contents of specified buffer into current buffer at point.
+Insert the contents of a specified buffer into current buffer at point.
@item M-x append-to-file
-Append region to contents of specified file, at the end.
+Append region to the contents of a specified file, at the end.
@end table
To accumulate text into a buffer, use @kbd{M-x append-to-buffer}.
@code{append-to-buffer} creates the buffer. The text is inserted
wherever point is in that buffer. If you have been using the buffer for
editing, the copied text goes into the middle of the text of the buffer,
-wherever point happens to be in it.
+starting from wherever point happens to be at that moment.
Point in that buffer is left at the end of the copied text, so
successive uses of @code{append-to-buffer} accumulate the text in the
@kbd{M-x prepend-to-buffer} is just like @code{append-to-buffer}
except that point in the other buffer is left before the copied text, so
successive prependings add text in reverse order. @kbd{M-x
-copy-to-buffer} is similar except that any existing text in the other
+copy-to-buffer} is similar, except that any existing text in the other
buffer is deleted, so the buffer is left containing just the text newly
copied into it.
- To retrieve the accumulated text from another buffer, use the command
-@kbd{M-x insert-buffer}; this too takes @var{buffername} as an argument.
-It inserts a copy of the text in buffer @var{buffername} into the
-selected buffer. You can alternatively select the other buffer for
-editing, then optionally move text from it by killing. @xref{Buffers},
-for background information on buffers.
+ To retrieve the accumulated text from another buffer, use the
+command @kbd{M-x insert-buffer}; this too takes @var{buffername} as an
+argument. It inserts a copy of the whole text in buffer
+@var{buffername} into the current buffer at point, and sets the mark
+after the inserted text. Alternatively, you can select the other
+buffer for editing, then copy text from it by killing.
+@xref{Buffers}, for background information on buffers.
Instead of accumulating text within Emacs, in a buffer, you can append
text directly into a file with @kbd{M-x append-to-file}, which takes
When you must specify a rectangle for a command to work on, you do it
by putting the mark at one corner and point at the opposite corner. The
rectangle thus specified is called the @dfn{region-rectangle} because
-you control it in about the same way the region is controlled. But
+you control it in much the same way as the region is controlled. But
remember that a given combination of point and mark values can be
interpreted either as a region or as a rectangle, depending on the
command that uses them.
@table @kbd
@item C-x r k
-Kill the text of the region-rectangle, saving its contents as the
+Kill the text of the region-rectangle, saving its contents as the
``last killed rectangle'' (@code{kill-rectangle}).
@item C-x r d
Delete the text of the region-rectangle (@code{delete-rectangle}).
Insert blank space to fill the space of the region-rectangle
(@code{open-rectangle}). This pushes the previous contents of the
region-rectangle rightward.
-@item M-x clear-rectangle
-Clear the region-rectangle by replacing its contents with spaces.
+@item C-x r c
+Clear the region-rectangle by replacing its contents with spaces
+(@code{clear-rectangle}).
@item M-x delete-whitespace-rectangle
Delete whitespace in each of the lines on the specified rectangle,
starting from the left edge column of the rectangle.
@item C-x r t @var{string} @key{RET}
-Insert @var{string} on each line of the region-rectangle
-(@code{string-rectangle}).
-@item M-x replace-rectangle @key{RET} @var{string} @key{RET}
-Replaces each line of the region-rectangle with @var{string}
+Replace rectangle contents with @var{string} on each line.
(@code{string-rectangle}).
+@item M-x string-insert-rectangle @key{RET} @var{string} @key{RET}
+Insert @var{string} on each line of the rectangle.
@end table
- The rectangle operations fall into two classes: commands deleting and
-inserting rectangles, and commands for blank rectangles.
+ The rectangle operations fall into two classes: commands for
+deleting and inserting rectangles, and commands for blank rectangles.
@kindex C-x r k
@kindex C-x r d
rectangle. The commands for these two ways are @kbd{C-x r d}
(@code{delete-rectangle}) and @kbd{C-x r k} (@code{kill-rectangle}). In
either case, the portion of each line that falls inside the rectangle's
-boundaries is deleted, causing following text (if any) on the line to
+boundaries is deleted, causing any following text on the line to
move left into the gap.
Note that ``killing'' a rectangle is not killing in the usual sense; the
(@code{yank-rectangle}). Yanking a rectangle is the opposite of killing
one. Point specifies where to put the rectangle's upper left corner.
The rectangle's first line is inserted there, the rectangle's second
-line is inserted at a position one line vertically down, and so on. The
-number of lines affected is determined by the height of the saved
-rectangle.
+line is inserted at the same horizontal position, but one line
+vertically down, and so on. The number of lines affected is determined
+by the height of the saved rectangle.
You can convert single-column lists into double-column lists using
rectangle killing and yanking; kill the second half of the list as a
@kindex C-x r o
@findex open-rectangle
+@kindex C-x r c
@findex clear-rectangle
There are two commands you can use for making blank rectangles:
-@kbd{M-x clear-rectangle} which blanks out existing text, and @kbd{C-x r
-o} (@code{open-rectangle}) which inserts a blank rectangle. Clearing a
-rectangle is equivalent to deleting it and then inserting a blank
-rectangle of the same size.
+@kbd{C-x r c} (@code{clear-rectangle}) which blanks out existing text,
+and @kbd{C-x r o} (@code{open-rectangle}) which inserts a blank
+rectangle. Clearing a rectangle is equivalent to deleting it and then
+inserting a blank rectangle of the same size.
@findex delete-whitespace-rectangle
The command @kbd{M-x delete-whitespace-rectangle} deletes horizontal
@kindex C-x r t
@findex string-rectangle
- The command @kbd{C-x r t} (@code{M-x string-rectangle}) inserts a
-string on each line of the region-rectangle before the rectangle,
-shifting text right.
-
-@findex replace-rectangle
- The command @kbd{M-x replace-rectangle} is similar to @kbd{C-x r t},
-but replaces the original rectangle. The string's width need not be
-the same as the width of the rectangle. If the string's width is
-less, the text after the rectangle shifts left; if the string is wider
-than the rectangle, the text after the rectangle shifts right.
+ The command @kbd{C-x r t} (@code{string-rectangle}) replaces the
+contents of a region-rectangle with a string on each line. The
+string's width need not be the same as the width of the rectangle. If
+the string's width is less, the text after the rectangle shifts left;
+if the string is wider than the rectangle, the text after the
+rectangle shifts right.
+
+@findex string-insert-rectangle
+ The command @kbd{M-x string-insert-rectangle} is similar to
+@code{string-rectangle}, but inserts the string on each line,
+shifting the original text to the right.
+
+@ignore
+ arch-tag: d8da8f96-0928-449a-816e-ff2d3497866c
+@end ignore