Next: Killing by Lines, Up: Deletion and Killing [Contents][Index]
14.1.1 DeletionDeletion 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.
Delete the previous character, or the text in the region if it is active (delete-backward-char
).
Delete the next character, or the text in the region if it is active (delete-forward-char
).
Delete the next character (delete-char
).
Delete spaces and tabs around point (delete-horizontal-space
).
Delete spaces and tabs around point, leaving one space.
Delete spaces and tabs around point in flexible ways (cycle-spacing
).
Delete blank lines around the current line (delete-blank-lines
).
Join two lines by deleting the intervening newline, along with any indentation following it (delete-indentation
).
We have already described the basic deletion commands DEL (delete-backward-char
), delete (delete-forward-char
), and C-d (delete-char
). See Erasing Text. With a numeric argument, they delete the specified number of characters. If the numeric argument is omitted or one, DEL and delete delete all the text in the region if it is active (see Operating on the Region).
The other delete commands are those that delete only whitespace characters: spaces, tabs and newlines. M-\ (delete-horizontal-space
) deletes all the spaces and tab characters before and after point. With a prefix argument, this only deletes spaces and tab characters before point.
M-x just-one-space deletes tabs and spaces around point, but leaves a single space before point, regardless of the number of spaces that existed previously (even if there were none before). With a numeric argument n, it leaves n spaces before point if n is positive; if n is negative, it deletes newlines in addition to spaces and tabs, leaving −n spaces before point.
The command cycle-spacing
(M-SPC) acts like a more flexible version of just-one-space
. It performs different space cleanup actions defined by cycle-spacing-actions
, in a cyclic manner, if you call it repeatedly in succession. By default, the first invocation does the same as just-one-space
, the second deletes all whitespace characters around point like delete-horizontal-space
, and the third restores the original whitespace characters; then it cycles. If invoked with a prefix argument, each action is given that value of the argument. The user option cycle-spacing-actions
can include other members; see the doc string of that option for the details.
C-x C-o (delete-blank-lines
) deletes all blank lines after the current line. If the current line is blank, it deletes all blank lines preceding the current line as well (leaving one blank line, the current line). On a solitary blank line, it deletes that line.
M-^ (delete-indentation
) joins the current line and the previous line, by deleting a newline and all surrounding spaces, usually leaving a single space. See M-^.
The command delete-duplicate-lines
searches the region for identical lines, and removes all but one copy of each. Normally it keeps the first instance of each repeated line, but with a C-u prefix argument it keeps the last. With a C-u C-u prefix argument, it only searches for adjacent identical lines. This is a more efficient mode of operation, useful when the lines have already been sorted. With a C-u C-u C-u prefix argument, it retains repeated blank lines.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4