ErgoEmacsEmacsLispBlogEmacsLispBuy Tutorial

12.3 Other Kill Commands

C-w
Kill region (kill-region). See Mark.
M-w
Save region as last killed text without actually killing it (kill-ring-save). Some programs call this “copying.”
M-d
Kill word (kill-word). See Words.
M-<DEL>
Kill word backwards (backward-kill-word).
C-x <DEL>
Kill back to beginning of sentence (backward-kill-sentence). See Sentences.
M-k
Kill to end of sentence (kill-sentence).
C-M-k
Kill the following balanced expression (kill-sexp). See Expressions.
M-z char
Kill through the next occurrence of char (zap-to-char).

Apart from C-k, the most commonly-used kill command is C-w (kill-region), which kills the text in the region (i.e., between point and mark). See Mark. If the mark is inactive when you type C-w, it first reactivates the mark where it was last set. The mark is deactivated at the end of the command.

The command M-w (kill-ring-save) copies the region into the kill ring without removing it from the buffer. This is approximately equivalent to C-w followed by C-/, except that M-w does not alter the undo history.

Emacs also provides commands to kill specific syntactic units: words, with M-<DEL> and M-d (see Words); balanced expressions, with C-M-k (see Expressions); and sentences, with C-x <DEL> and M-k (see Sentences).

The command M-z (zap-to-char) combines killing with searching: it reads a character and kills from point up to (and including) the next occurrence of that character in the buffer. A numeric argument acts as a repeat count; a negative argument means to search backward and kill text before point.

blog comments powered by Disqus