ErgoEmacsEmacsLispBlogEmacsLispBuy Tutorial

7.3 Erasing Text

<DEL>
<Backspace>
Delete the character before point (delete-backward-char).
C-d
<Delete>
Delete the character after point (delete-char).
C-k
Kill to the end of the line (kill-line).
M-d
Kill forward to the end of the next word (kill-word).
M-<DEL>
Kill back to the beginning of the previous word (backward-kill-word).

The key <DEL> (delete-backward-char) removes the character before point, moving the cursor and all the characters after it backwards. On most keyboards, <DEL> is labelled <Backspace>, but we refer to it as <DEL> in this manual. Do not confuse <DEL> with another key, labelled <Delete>, that exists on many keyboards; we will discuss <Delete> momentarily.

Typing <DEL> when the cursor is at the beginning of a line deletes the preceding newline character, joining the line with the one before it.

On some text-only terminals, Emacs may not recognize the <DEL> key properly. If <DEL> does not do the right thing (⁖, if it deletes characters forwards), see DEL Does Not Delete.

The key C-d (delete-char) deletes the character after point, i.e., the character under the cursor. This shifts the rest of the text on the line to the left. If you type C-d at the end of a line, it joins that line with the following line. This command is also bound to the key labelled <Delete> on many keyboards.

To erase a larger amount of text, use the C-k key, which erases (kills) a line at a time. If you type C-k at the beginning or middle of a line, it kills all the text up to the end of the line. If you type C-k at the end of a line, it joins that line with the following line.

To learn more about killing text, see Killing.

blog comments powered by Disqus