Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Next: , Up: Killing


13.1 Deletion

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.

C-d
<Delete>
Delete next character (delete-char). If your keyboard has a <Delete> function key (usually located in the edit keypad), Emacs binds it to delete-char as well.
<DEL>
<BS>
Delete previous character (delete-backward-char). Some keyboards refer to this key as a “backspace key” and label it with a left arrow.
M-\
Delete spaces and tabs around point (delete-horizontal-space).
M-<SPC>
Delete spaces and tabs around point, leaving one space (just-one-space).
C-x C-o
Delete blank lines around the current line (delete-blank-lines).
M-^
Join two lines by deleting the intervening newline, along with any indentation following it (delete-indentation).

The most basic delete commands are C-d (delete-char) and <DEL> (delete-backward-char). C-d deletes the character after point, the one the cursor is “on top of.” This doesn't move point. <DEL> deletes the character before the cursor, and moves point back. You can delete newlines like any other characters in the buffer; deleting a newline joins two lines. Actually, C-d and <DEL> aren't always delete commands; when given arguments, they kill instead, since they can erase more than one character this way.

Every keyboard has a large key, labeled <DEL>, <BACKSPACE>, <BS> or <DELETE>, which is a short distance above the <RET> or <ENTER> key and is normally used for erasing what you have typed. Regardless of the actual name on the key, in Emacs it is equivalent to <DEL>—or it should be.

Many keyboards (including standard PC keyboards) have a <BACKSPACE> key a short ways above <RET> or <ENTER>, and a <DELETE> key elsewhere. In that case, the <BACKSPACE> key is <DEL>, and the <DELETE> key is equivalent to C-d—or it should be.

Why do we say “or it should be”? When Emacs starts up using a window system, it determines automatically which key or keys should be equivalent to <DEL>. As a result, <BACKSPACE> and/or <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 <DEL>. See DEL Does Not Delete, for how to do this.

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 ASCII <DEL> character deletes, and the ASCII <BS> (backspace) character asks for help (it is the same as 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 DEL Does Not Delete.

The other delete commands are those which delete only whitespace characters: spaces, tabs and newlines. M-\ (delete-horizontal-space) deletes all the spaces and tab characters before and after point. M-<SPC> (just-one-space) does likewise but leaves a single space after 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 after point.

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-^.


 
 
  Published under the terms of the GNU General Public License Design by Interspire