manpagez: man pages & more
info emacs
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.1 Inserting Text

Typing printing characters inserts them into the text you are editing. It inserts them into the buffer at the cursor; more precisely, it inserts them at point, but the cursor normally shows where point is. See section Point.

Insertion moves the cursor forward, and the following text moves forward with the cursor. If the text in the buffer is ‘FOOBAR’, with the cursor before the ‘B’, and you type XX, you get ‘FOOXXBAR’, with the cursor still before the ‘B’.

To delete text you have just inserted, use the large key labeled <DEL>, <BACKSPACE> or <DELETE> which is a short distance above the <RET> or <ENTER> key. Regardless of the label on that key, Emacs thinks of it as <DEL>, and that's what we call it in this manual. <DEL> is the key you normally use outside Emacs to erase the last character that you typed.

The <DEL> key deletes the character before the cursor. As a consequence, the cursor and all the characters after it move backwards. If you type a printing character and then type <DEL>, they cancel out.

On most computers, Emacs sets up <DEL> automatically. In some cases, especially with text-only terminals, Emacs may guess wrong. If the key that ought to erase the last character doesn't do it in Emacs, see If <DEL> Fails to Delete.

Most PC keyboards have both a <BACKSPACE> key a little ways above <RET> or <ENTER>, and a <DELETE> key elsewhere. On these keyboards, Emacs tries to set up <BACKSPACE> as <DEL>. The <DELETE> key deletes “forwards” like C-d (see below), which means it deletes the character underneath the cursor (after point).

To end a line and start typing a new one, type <RET>. (This key may be labeled <RETURN> or <ENTER>, but in Emacs we call it <RET>.) This inserts a newline character in the buffer. If point is at the end of the line, this creates a new blank line after it. If point is in the middle of a line, the effect is to split that line. Typing <DEL> when the cursor is at the beginning of a line deletes the preceding newline character, thus joining the line with the one before it.

Emacs can split lines automatically when they become too long, if you turn on a special minor mode called Auto Fill mode. See section Filling Text, for Auto Fill mode and other methods of filling text.

If you prefer printing characters to replace (overwrite) existing text, rather than shove it to the right, you should enable Overwrite mode, a minor mode. See section Minor Modes.

Only printing characters and <SPC> insert themselves in Emacs. Other characters act as editing commands and do not insert themselves. These include control characters, and characters with codes above 200 octal. If you need to insert one of these characters in the buffer, you must quote it by typing the character Control-q (quoted-insert) first. (This character's name is normally written C-q for short.) There are two ways to use C-q:

When multibyte characters are enabled, if you specify a code in the range 0200 through 0377 octal, C-q assumes that you intend to use some ISO 8859-n character set, and converts the specified code to the corresponding Emacs character code. See section Enabling Multibyte Characters. You select which of the ISO 8859 character sets to use through your choice of language environment (see section Language Environments).

To use decimal or hexadecimal instead of octal, set the variable read-quoted-char-radix to 10 or 16. If the radix is greater than 10, some letters starting with a serve as part of a character code, just like digits.

A numeric argument tells C-q how many copies of the quoted character to insert (see section Numeric Arguments).

Customization information: <DEL> in most modes runs the command delete-backward-char; <RET> runs the command newline, and self-inserting printing characters run the command self-insert, which inserts whatever character you typed. Some major modes rebind <DEL> to other commands.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.