| 1 |
This is ../info/emacs, produced by makeinfo version 4.3 from emacs.texi. |
|---|
| 2 |
|
|---|
| 3 |
This is the Fourteenth edition of the `GNU Emacs Manual', updated |
|---|
| 4 |
for Emacs version 21.3. |
|---|
| 5 |
|
|---|
| 6 |
INFO-DIR-SECTION Emacs |
|---|
| 7 |
START-INFO-DIR-ENTRY |
|---|
| 8 |
* Emacs: (emacs). The extensible self-documenting text editor. |
|---|
| 9 |
END-INFO-DIR-ENTRY |
|---|
| 10 |
|
|---|
| 11 |
Published by the Free Software Foundation 59 Temple Place, Suite 330 |
|---|
| 12 |
Boston, MA 02111-1307 USA |
|---|
| 13 |
|
|---|
| 14 |
Copyright (C) |
|---|
| 15 |
1985,1986,1987,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002 |
|---|
| 16 |
Free Software Foundation, Inc. |
|---|
| 17 |
|
|---|
| 18 |
Permission is granted to copy, distribute and/or modify this document |
|---|
| 19 |
under the terms of the GNU Free Documentation License, Version 1.1 or |
|---|
| 20 |
any later version published by the Free Software Foundation; with the |
|---|
| 21 |
Invariant Sections being "The GNU Manifesto", "Distribution" and "GNU |
|---|
| 22 |
GENERAL PUBLIC LICENSE", with the Front-Cover texts being "A GNU |
|---|
| 23 |
Manual," and with the Back-Cover Texts as in (a) below. A copy of the |
|---|
| 24 |
license is included in the section entitled "GNU Free Documentation |
|---|
| 25 |
License." |
|---|
| 26 |
|
|---|
| 27 |
(a) The FSF's Back-Cover Text is: "You have freedom to copy and |
|---|
| 28 |
modify this GNU Manual, like GNU software. Copies published by the Free |
|---|
| 29 |
Software Foundation raise funds for GNU development." |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
File: emacs, Node: Mode Line, Next: Menu Bar, Prev: Echo Area, Up: Screen |
|---|
| 33 |
|
|---|
| 34 |
The Mode Line |
|---|
| 35 |
============= |
|---|
| 36 |
|
|---|
| 37 |
Each text window's last line is a "mode line", which describes what |
|---|
| 38 |
is going on in that window. When there is only one text window, the |
|---|
| 39 |
mode line appears right above the echo area; it is the next-to-last |
|---|
| 40 |
line in the frame. The mode line starts and ends with dashes. On a |
|---|
| 41 |
text-mode display, the mode line is in inverse video if the terminal |
|---|
| 42 |
supports that; on a graphics display, the mode line has a 3D box |
|---|
| 43 |
appearance to help it stand out. |
|---|
| 44 |
|
|---|
| 45 |
Normally, the mode line looks like this: |
|---|
| 46 |
|
|---|
| 47 |
-CS:CH BUF (MAJOR MINOR)--LINE--POS------ |
|---|
| 48 |
|
|---|
| 49 |
This gives information about the buffer being displayed in the window: |
|---|
| 50 |
the buffer's name, what major and minor modes are in use, whether the |
|---|
| 51 |
buffer's text has been changed, and how far down the buffer you are |
|---|
| 52 |
currently looking. |
|---|
| 53 |
|
|---|
| 54 |
CH contains two stars `**' if the text in the buffer has been edited |
|---|
| 55 |
(the buffer is "modified"), or `--' if the buffer has not been edited. |
|---|
| 56 |
For a read-only buffer, it is `%*' if the buffer is modified, and `%%' |
|---|
| 57 |
otherwise. |
|---|
| 58 |
|
|---|
| 59 |
BUF is the name of the window's "buffer". In most cases this is the |
|---|
| 60 |
same as the name of a file you are editing. *Note Buffers::. |
|---|
| 61 |
|
|---|
| 62 |
The buffer displayed in the selected window (the window that the |
|---|
| 63 |
cursor is in) is also Emacs's current buffer, the one that editing |
|---|
| 64 |
takes place in. When we speak of what some command does to "the |
|---|
| 65 |
buffer," we are talking about the current buffer. |
|---|
| 66 |
|
|---|
| 67 |
LINE is `L' followed by the current line number of point. This is |
|---|
| 68 |
present when Line Number mode is enabled (which it normally is). You |
|---|
| 69 |
can optionally display the current column number too, by turning on |
|---|
| 70 |
Column Number mode (which is not enabled by default because it is |
|---|
| 71 |
somewhat slower). *Note Optional Mode Line::. |
|---|
| 72 |
|
|---|
| 73 |
POS tells you whether there is additional text above the top of the |
|---|
| 74 |
window, or below the bottom. If your buffer is small and it is all |
|---|
| 75 |
visible in the window, POS is `All'. Otherwise, it is `Top' if you are |
|---|
| 76 |
looking at the beginning of the buffer, `Bot' if you are looking at the |
|---|
| 77 |
end of the buffer, or `NN%', where NN is the percentage of the buffer |
|---|
| 78 |
above the top of the window. |
|---|
| 79 |
|
|---|
| 80 |
MAJOR is the name of the "major mode" in effect in the buffer. At |
|---|
| 81 |
any time, each buffer is in one and only one of the possible major |
|---|
| 82 |
modes. The major modes available include Fundamental mode (the least |
|---|
| 83 |
specialized), Text mode, Lisp mode, C mode, Texinfo mode, and many |
|---|
| 84 |
others. *Note Major Modes::, for details of how the modes differ and |
|---|
| 85 |
how to select one. |
|---|
| 86 |
|
|---|
| 87 |
Some major modes display additional information after the major mode |
|---|
| 88 |
name. For example, Rmail buffers display the current message number and |
|---|
| 89 |
the total number of messages. Compilation buffers and Shell buffers |
|---|
| 90 |
display the status of the subprocess. |
|---|
| 91 |
|
|---|
| 92 |
MINOR is a list of some of the "minor modes" that are turned on at |
|---|
| 93 |
the moment in the window's chosen buffer. For example, `Fill' means |
|---|
| 94 |
that Auto Fill mode is on. `Abbrev' means that Word Abbrev mode is on. |
|---|
| 95 |
`Ovwrt' means that Overwrite mode is on. *Note Minor Modes::, for |
|---|
| 96 |
more information. `Narrow' means that the buffer being displayed has |
|---|
| 97 |
editing restricted to only a portion of its text. This is not really a |
|---|
| 98 |
minor mode, but is like one. *Note Narrowing::. `Def' means that a |
|---|
| 99 |
keyboard macro is being defined. *Note Keyboard Macros::. |
|---|
| 100 |
|
|---|
| 101 |
In addition, if Emacs is currently inside a recursive editing level, |
|---|
| 102 |
square brackets (`[...]') appear around the parentheses that surround |
|---|
| 103 |
the modes. If Emacs is in one recursive editing level within another, |
|---|
| 104 |
double square brackets appear, and so on. Since recursive editing |
|---|
| 105 |
levels affect Emacs globally, not just one buffer, the square brackets |
|---|
| 106 |
appear in every window's mode line or not in any of them. *Note |
|---|
| 107 |
Recursive Edit::. |
|---|
| 108 |
|
|---|
| 109 |
Non-windowing terminals can only show a single Emacs frame at a time |
|---|
| 110 |
(*note Frames::). On such terminals, the mode line displays the name of |
|---|
| 111 |
the selected frame, after CH. The initial frame's name is `F1'. |
|---|
| 112 |
|
|---|
| 113 |
CS states the coding system used for the file you are editing. A |
|---|
| 114 |
dash indicates the default state of affairs: no code conversion, except |
|---|
| 115 |
for end-of-line translation if the file contents call for that. `=' |
|---|
| 116 |
means no conversion whatsoever. Nontrivial code conversions are |
|---|
| 117 |
represented by various letters--for example, `1' refers to ISO Latin-1. |
|---|
| 118 |
*Note Coding Systems::, for more information. If you are using an |
|---|
| 119 |
input method, a string of the form `I>' is added to the beginning of |
|---|
| 120 |
CS; I identifies the input method. (Some input methods show `+' or `@' |
|---|
| 121 |
instead of `>'.) *Note Input Methods::. |
|---|
| 122 |
|
|---|
| 123 |
When you are using a character-only terminal (not a window system), |
|---|
| 124 |
CS uses three characters to describe, respectively, the coding system |
|---|
| 125 |
for keyboard input, the coding system for terminal output, and the |
|---|
| 126 |
coding system used for the file you are editing. |
|---|
| 127 |
|
|---|
| 128 |
When multibyte characters are not enabled, CS does not appear at |
|---|
| 129 |
all. *Note Enabling Multibyte::. |
|---|
| 130 |
|
|---|
| 131 |
The colon after CS can change to another string in certain |
|---|
| 132 |
circumstances. Emacs uses newline characters to separate lines in the |
|---|
| 133 |
buffer. Some files use different conventions for separating lines: |
|---|
| 134 |
either carriage-return linefeed (the MS-DOS convention) or just |
|---|
| 135 |
carriage-return (the Macintosh convention). If the buffer's file uses |
|---|
| 136 |
carriage-return linefeed, the colon changes to either a backslash (`\') |
|---|
| 137 |
or `(DOS)', depending on the operating system. If the file uses just |
|---|
| 138 |
carriage-return, the colon indicator changes to either a forward slash |
|---|
| 139 |
(`/') or `(Mac)'. On some systems, Emacs displays `(Unix)' instead of |
|---|
| 140 |
the colon even for files that use newline to separate lines. |
|---|
| 141 |
|
|---|
| 142 |
You can customize the mode line display for each of the end-of-line |
|---|
| 143 |
formats by setting each of the variables `eol-mnemonic-unix', |
|---|
| 144 |
`eol-mnemonic-dos', `eol-mnemonic-mac', and `eol-mnemonic-undecided' to |
|---|
| 145 |
any string you find appropriate. *Note Variables::, for an explanation |
|---|
| 146 |
of how to set variables. |
|---|
| 147 |
|
|---|
| 148 |
*Note Optional Mode Line::, for features that add other handy |
|---|
| 149 |
information to the mode line, such as the current column number of |
|---|
| 150 |
point, the current time, and whether new mail for you has arrived. |
|---|
| 151 |
|
|---|
| 152 |
The mode line is mouse-sensitive; when you move the mouse across |
|---|
| 153 |
various parts of it, Emacs displays help text to say what a click in |
|---|
| 154 |
that place will do. *Note Mode Line Mouse::. |
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
File: emacs, Node: Menu Bar, Prev: Mode Line, Up: Screen |
|---|
| 158 |
|
|---|
| 159 |
The Menu Bar |
|---|
| 160 |
============ |
|---|
| 161 |
|
|---|
| 162 |
Each Emacs frame normally has a "menu bar" at the top which you can |
|---|
| 163 |
use to perform certain common operations. There's no need to list them |
|---|
| 164 |
here, as you can more easily see for yourself. |
|---|
| 165 |
|
|---|
| 166 |
When you are using a window system, you can use the mouse to choose a |
|---|
| 167 |
command from the menu bar. An arrow pointing right, after the menu |
|---|
| 168 |
item, indicates that the item leads to a subsidiary menu; `...' at the |
|---|
| 169 |
end means that the command will read arguments from the keyboard before |
|---|
| 170 |
it actually does anything. |
|---|
| 171 |
|
|---|
| 172 |
To view the full command name and documentation for a menu item, type |
|---|
| 173 |
`C-h k', and then select the menu bar with the mouse in the usual way |
|---|
| 174 |
(*note Key Help::). |
|---|
| 175 |
|
|---|
| 176 |
On text-only terminals with no mouse, you can use the menu bar by |
|---|
| 177 |
typing `M-`' or <F10> (these run the command `tmm-menubar'). This |
|---|
| 178 |
command enters a mode in which you can select a menu item from the |
|---|
| 179 |
keyboard. A provisional choice appears in the echo area. You can use |
|---|
| 180 |
the left and right arrow keys to move through the menu to different |
|---|
| 181 |
choices. When you have found the choice you want, type <RET> to select |
|---|
| 182 |
it. |
|---|
| 183 |
|
|---|
| 184 |
Each menu item also has an assigned letter or digit which designates |
|---|
| 185 |
that item; it is usually the initial of some word in the item's name. |
|---|
| 186 |
This letter or digit is separated from the item name by `=>'. You can |
|---|
| 187 |
type the item's letter or digit to select the item. |
|---|
| 188 |
|
|---|
| 189 |
Some of the commands in the menu bar have ordinary key bindings as |
|---|
| 190 |
well; if so, the menu lists one equivalent key binding in parentheses |
|---|
| 191 |
after the item itself. |
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
File: emacs, Node: User Input, Next: Keys, Prev: Screen, Up: Top |
|---|
| 195 |
|
|---|
| 196 |
Kinds of User Input |
|---|
| 197 |
=================== |
|---|
| 198 |
|
|---|
| 199 |
GNU Emacs uses an extension of the ASCII character set for keyboard |
|---|
| 200 |
input; it also accepts non-character input events including function |
|---|
| 201 |
keys and mouse button actions. |
|---|
| 202 |
|
|---|
| 203 |
ASCII consists of 128 character codes. Some of these codes are |
|---|
| 204 |
assigned graphic symbols such as `a' and `='; the rest are control |
|---|
| 205 |
characters, such as `Control-a' (usually written `C-a' for short). |
|---|
| 206 |
`C-a' gets its name from the fact that you type it by holding down the |
|---|
| 207 |
<CTRL> key while pressing `a'. |
|---|
| 208 |
|
|---|
| 209 |
Some ASCII control characters have special names, and most terminals |
|---|
| 210 |
have special keys you can type them with: for example, <RET>, <TAB>, |
|---|
| 211 |
<DEL> and <ESC>. The space character is usually referred to below as |
|---|
| 212 |
<SPC>, even though strictly speaking it is a graphic character whose |
|---|
| 213 |
graphic happens to be blank. Some keyboards have a key labeled |
|---|
| 214 |
"linefeed" which is an alias for `C-j'. |
|---|
| 215 |
|
|---|
| 216 |
Emacs extends the ASCII character set with thousands more printing |
|---|
| 217 |
characters (*note International::), additional control characters, and a |
|---|
| 218 |
few more modifiers that can be combined with any character. |
|---|
| 219 |
|
|---|
| 220 |
On ASCII terminals, there are only 32 possible control characters. |
|---|
| 221 |
These are the control variants of letters and `@[]\^_'. In addition, |
|---|
| 222 |
the shift key is meaningless with control characters: `C-a' and `C-A' |
|---|
| 223 |
are the same character, and Emacs cannot distinguish them. |
|---|
| 224 |
|
|---|
| 225 |
But the Emacs character set has room for control variants of all |
|---|
| 226 |
printing characters, and for distinguishing between `C-a' and `C-A'. |
|---|
| 227 |
The X Window System makes it possible to enter all these characters. |
|---|
| 228 |
For example, `C--' (that's Control-Minus) and `C-5' are meaningful |
|---|
| 229 |
Emacs commands under X. |
|---|
| 230 |
|
|---|
| 231 |
Another Emacs character-set extension is additional modifier bits. |
|---|
| 232 |
Only one modifier bit is commonly used; it is called Meta. Every |
|---|
| 233 |
character has a Meta variant; examples include `Meta-a' (normally |
|---|
| 234 |
written `M-a', for short), `M-A' (not the same character as `M-a', but |
|---|
| 235 |
those two characters normally have the same meaning in Emacs), |
|---|
| 236 |
`M-<RET>', and `M-C-a'. For reasons of tradition, we usually write |
|---|
| 237 |
`C-M-a' rather than `M-C-a'; logically speaking, the order in which the |
|---|
| 238 |
modifier keys <CTRL> and <META> are mentioned does not matter. |
|---|
| 239 |
|
|---|
| 240 |
Some terminals have a <META> key, and allow you to type Meta |
|---|
| 241 |
characters by holding this key down. Thus, `Meta-a' is typed by |
|---|
| 242 |
holding down <META> and pressing `a'. The <META> key works much like |
|---|
| 243 |
the <SHIFT> key. Such a key is not always labeled <META>, however, as |
|---|
| 244 |
this function is often a special option for a key with some other |
|---|
| 245 |
primary purpose. Sometimes it is labeled <ALT> or <EDIT>; on a Sun |
|---|
| 246 |
keyboard, it may have a diamond on it. |
|---|
| 247 |
|
|---|
| 248 |
If there is no <META> key, you can still type Meta characters using |
|---|
| 249 |
two-character sequences starting with <ESC>. Thus, you can enter `M-a' |
|---|
| 250 |
by typing `<ESC> a'. You can enter `C-M-a' by typing `<ESC> C-a'. |
|---|
| 251 |
<ESC> is allowed on terminals with <META> keys, too, in case you have |
|---|
| 252 |
formed a habit of using it. |
|---|
| 253 |
|
|---|
| 254 |
The X Window System provides several other modifier keys that can be |
|---|
| 255 |
applied to any input character. These are called <SUPER>, <HYPER> and |
|---|
| 256 |
<ALT>. We write `s-', `H-' and `A-' to say that a character uses these |
|---|
| 257 |
modifiers. Thus, `s-H-C-x' is short for `Super-Hyper-Control-x'. Not |
|---|
| 258 |
all X terminals actually provide keys for these modifier flags--in |
|---|
| 259 |
fact, many terminals have a key labeled <ALT> which is really a <META> |
|---|
| 260 |
key. The standard key bindings of Emacs do not include any characters |
|---|
| 261 |
with these modifiers. But you can assign them meanings of your own by |
|---|
| 262 |
customizing Emacs. |
|---|
| 263 |
|
|---|
| 264 |
Keyboard input includes keyboard keys that are not characters at all: |
|---|
| 265 |
for example function keys and arrow keys. Mouse buttons are also |
|---|
| 266 |
outside the gamut of characters. You can modify these events with the |
|---|
| 267 |
modifier keys <CTRL>, <META>, <SUPER>, <HYPER> and <ALT>, just like |
|---|
| 268 |
keyboard characters. |
|---|
| 269 |
|
|---|
| 270 |
Input characters and non-character inputs are collectively called |
|---|
| 271 |
"input events". *Note Input Events: (elisp)Input Events, for more |
|---|
| 272 |
information. If you are not doing Lisp programming, but simply want to |
|---|
| 273 |
redefine the meaning of some characters or non-character events, see |
|---|
| 274 |
*Note Customization::. |
|---|
| 275 |
|
|---|
| 276 |
ASCII terminals cannot really send anything to the computer except |
|---|
| 277 |
ASCII characters. These terminals use a sequence of characters to |
|---|
| 278 |
represent each function key. But that is invisible to the Emacs user, |
|---|
| 279 |
because the keyboard input routines recognize these special sequences |
|---|
| 280 |
and convert them to function key events before any other part of Emacs |
|---|
| 281 |
gets to see them. |
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
File: emacs, Node: Keys, Next: Commands, Prev: User Input, Up: Top |
|---|
| 285 |
|
|---|
| 286 |
Keys |
|---|
| 287 |
==== |
|---|
| 288 |
|
|---|
| 289 |
A "key sequence" ("key", for short) is a sequence of input events |
|---|
| 290 |
that are meaningful as a unit--as "a single command." Some Emacs |
|---|
| 291 |
command sequences are just one character or one event; for example, |
|---|
| 292 |
just `C-f' is enough to move forward one character in the buffer. But |
|---|
| 293 |
Emacs also has commands that take two or more events to invoke. |
|---|
| 294 |
|
|---|
| 295 |
If a sequence of events is enough to invoke a command, it is a |
|---|
| 296 |
"complete key". Examples of complete keys include `C-a', `X', <RET>, |
|---|
| 297 |
<NEXT> (a function key), <DOWN> (an arrow key), `C-x C-f', and `C-x 4 |
|---|
| 298 |
C-f'. If it isn't long enough to be complete, we call it a "prefix |
|---|
| 299 |
key". The above examples show that `C-x' and `C-x 4' are prefix keys. |
|---|
| 300 |
Every key sequence is either a complete key or a prefix key. |
|---|
| 301 |
|
|---|
| 302 |
Most single characters constitute complete keys in the standard Emacs |
|---|
| 303 |
command bindings. A few of them are prefix keys. A prefix key combines |
|---|
| 304 |
with the following input event to make a longer key sequence, which may |
|---|
| 305 |
itself be complete or a prefix. For example, `C-x' is a prefix key, so |
|---|
| 306 |
`C-x' and the next input event combine to make a two-event key |
|---|
| 307 |
sequence. Most of these key sequences are complete keys, including |
|---|
| 308 |
`C-x C-f' and `C-x b'. A few, such as `C-x 4' and `C-x r', are |
|---|
| 309 |
themselves prefix keys that lead to three-event key sequences. There's |
|---|
| 310 |
no limit to the length of a key sequence, but in practice people rarely |
|---|
| 311 |
use sequences longer than four events. |
|---|
| 312 |
|
|---|
| 313 |
By contrast, you can't add more events onto a complete key. For |
|---|
| 314 |
example, the two-event sequence `C-f C-k' is not a key, because the |
|---|
| 315 |
`C-f' is a complete key in itself. It's impossible to give `C-f C-k' |
|---|
| 316 |
an independent meaning as a command. `C-f C-k' is two key sequences, |
|---|
| 317 |
not one. |
|---|
| 318 |
|
|---|
| 319 |
All told, the prefix keys in Emacs are `C-c', `C-h', `C-x', `C-x |
|---|
| 320 |
<RET>', `C-x @', `C-x a', `C-x n', `C-x r', `C-x v', `C-x 4', `C-x 5', |
|---|
| 321 |
`C-x 6', <ESC>, and `M-g'. But this list is not cast in concrete; it is |
|---|
| 322 |
just a matter of Emacs's standard key bindings. If you customize Emacs, |
|---|
| 323 |
you can make new prefix keys, or eliminate these. *Note Key Bindings::. |
|---|
| 324 |
|
|---|
| 325 |
If you do make or eliminate prefix keys, that changes the set of |
|---|
| 326 |
possible key sequences. For example, if you redefine `C-f' as a |
|---|
| 327 |
prefix, `C-f C-k' automatically becomes a key (complete, unless you |
|---|
| 328 |
define that too as a prefix). Conversely, if you remove the prefix |
|---|
| 329 |
definition of `C-x 4', then `C-x 4 f' (or `C-x 4 ANYTHING') is no |
|---|
| 330 |
longer a key. |
|---|
| 331 |
|
|---|
| 332 |
Typing the help character (`C-h' or <F1>) after a prefix key |
|---|
| 333 |
displays a list of the commands starting with that prefix. There are a |
|---|
| 334 |
few prefix keys for which `C-h' does not work--for historical reasons, |
|---|
| 335 |
they have other meanings for `C-h' which are not easy to change. But |
|---|
| 336 |
<F1> should work for all prefix keys. |
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 |
File: emacs, Node: Commands, Next: Text Characters, Prev: Keys, Up: Top |
|---|
| 340 |
|
|---|
| 341 |
Keys and Commands |
|---|
| 342 |
================= |
|---|
| 343 |
|
|---|
| 344 |
This manual is full of passages that tell you what particular keys |
|---|
| 345 |
do. But Emacs does not assign meanings to keys directly. Instead, |
|---|
| 346 |
Emacs assigns meanings to named "commands", and then gives keys their |
|---|
| 347 |
meanings by "binding" them to commands. |
|---|
| 348 |
|
|---|
| 349 |
Every command has a name chosen by a programmer. The name is usually |
|---|
| 350 |
made of a few English words separated by dashes; for example, |
|---|
| 351 |
`next-line' or `forward-word'. A command also has a "function |
|---|
| 352 |
definition" which is a Lisp program; this is what makes the command do |
|---|
| 353 |
what it does. In Emacs Lisp, a command is actually a special kind of |
|---|
| 354 |
Lisp function; one which specifies how to read arguments for it and |
|---|
| 355 |
call it interactively. For more information on commands and functions, |
|---|
| 356 |
see *Note What Is a Function: (elisp)What Is a Function. (The |
|---|
| 357 |
definition we use in this manual is simplified slightly.) |
|---|
| 358 |
|
|---|
| 359 |
The bindings between keys and commands are recorded in various tables |
|---|
| 360 |
called "keymaps". *Note Keymaps::. |
|---|
| 361 |
|
|---|
| 362 |
When we say that "`C-n' moves down vertically one line" we are |
|---|
| 363 |
glossing over a distinction that is irrelevant in ordinary use but is |
|---|
| 364 |
vital in understanding how to customize Emacs. It is the command |
|---|
| 365 |
`next-line' that is programmed to move down vertically. `C-n' has this |
|---|
| 366 |
effect _because_ it is bound to that command. If you rebind `C-n' to |
|---|
| 367 |
the command `forward-word' then `C-n' will move forward by words |
|---|
| 368 |
instead. Rebinding keys is a common method of customization. |
|---|
| 369 |
|
|---|
| 370 |
In the rest of this manual, we usually ignore this subtlety to keep |
|---|
| 371 |
things simple. To give the information needed for customization, we |
|---|
| 372 |
state the name of the command which really does the work in parentheses |
|---|
| 373 |
after mentioning the key that runs it. For example, we will say that |
|---|
| 374 |
"The command `C-n' (`next-line') moves point vertically down," meaning |
|---|
| 375 |
that `next-line' is a command that moves vertically down, and `C-n' is |
|---|
| 376 |
a key that is normally bound to it. |
|---|
| 377 |
|
|---|
| 378 |
While we are on the subject of information for customization only, |
|---|
| 379 |
it's a good time to tell you about "variables". Often the description |
|---|
| 380 |
of a command will say, "To change this, set the variable `mumble-foo'." |
|---|
| 381 |
A variable is a name used to remember a value. Most of the variables |
|---|
| 382 |
documented in this manual exist just to facilitate customization: some |
|---|
| 383 |
command or other part of Emacs examines the variable and behaves |
|---|
| 384 |
differently according to the value that you set. Until you are |
|---|
| 385 |
interested in customizing, you can ignore the information about |
|---|
| 386 |
variables. When you are ready to be interested, read the basic |
|---|
| 387 |
information on variables, and then the information on individual |
|---|
| 388 |
variables will make sense. *Note Variables::. |
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 |
File: emacs, Node: Text Characters, Next: Entering Emacs, Prev: Commands, Up: Top |
|---|
| 392 |
|
|---|
| 393 |
Character Set for Text |
|---|
| 394 |
====================== |
|---|
| 395 |
|
|---|
| 396 |
Text in Emacs buffers is a sequence of 8-bit bytes. Each byte can |
|---|
| 397 |
hold a single ASCII character. Both ASCII control characters (octal |
|---|
| 398 |
codes 000 through 037, and 0177) and ASCII printing characters (codes |
|---|
| 399 |
040 through 0176) are allowed; however, non-ASCII control characters |
|---|
| 400 |
cannot appear in a buffer. The other modifier flags used in keyboard |
|---|
| 401 |
input, such as Meta, are not allowed in buffers either. |
|---|
| 402 |
|
|---|
| 403 |
Some ASCII control characters serve special purposes in text, and |
|---|
| 404 |
have special names. For example, the newline character (octal code |
|---|
| 405 |
012) is used in the buffer to end a line, and the tab character (octal |
|---|
| 406 |
code 011) is used for indenting to the next tab stop column (normally |
|---|
| 407 |
every 8 columns). *Note Text Display::. |
|---|
| 408 |
|
|---|
| 409 |
Non-ASCII printing characters can also appear in buffers. When |
|---|
| 410 |
multibyte characters are enabled, you can use any of the non-ASCII |
|---|
| 411 |
printing characters that Emacs supports. They have character codes |
|---|
| 412 |
starting at 256, octal 0400, and each one is represented as a sequence |
|---|
| 413 |
of two or more bytes. *Note International::. Single-byte characters |
|---|
| 414 |
with codes 128 through 255 can also appear in multibyte buffers. |
|---|
| 415 |
|
|---|
| 416 |
If you disable multibyte characters, then you can use only one |
|---|
| 417 |
alphabet of non-ASCII characters, but they all fit in one byte. They |
|---|
| 418 |
use codes 0200 through 0377. *Note Single-Byte Character Support::. |
|---|
| 419 |
|
|---|
| 420 |
|
|---|
| 421 |
File: emacs, Node: Entering Emacs, Next: Exiting, Prev: Text Characters, Up: Top |
|---|
| 422 |
|
|---|
| 423 |
Entering and Exiting Emacs |
|---|
| 424 |
************************** |
|---|
| 425 |
|
|---|
| 426 |
The usual way to invoke Emacs is with the shell command `emacs'. |
|---|
| 427 |
Emacs clears the screen and then displays an initial help message and |
|---|
| 428 |
copyright notice. Some operating systems discard all type-ahead when |
|---|
| 429 |
Emacs starts up; they give Emacs no way to prevent this. Therefore, it |
|---|
| 430 |
is advisable to wait until Emacs clears the screen before typing your |
|---|
| 431 |
first editing command. |
|---|
| 432 |
|
|---|
| 433 |
If you run Emacs from a shell window under the X Window System, run |
|---|
| 434 |
it in the background with `emacs&'. This way, Emacs does not tie up |
|---|
| 435 |
the shell window, so you can use that to run other shell commands while |
|---|
| 436 |
Emacs operates its own X windows. You can begin typing Emacs commands |
|---|
| 437 |
as soon as you direct your keyboard input to the Emacs frame. |
|---|
| 438 |
|
|---|
| 439 |
When Emacs starts up, it creates a buffer named `*scratch*'. That's |
|---|
| 440 |
the buffer you start out in. The `*scratch*' buffer uses Lisp |
|---|
| 441 |
Interaction mode; you can use it to type Lisp expressions and evaluate |
|---|
| 442 |
them, or you can ignore that capability and simply doodle. (You can |
|---|
| 443 |
specify a different major mode for this buffer by setting the variable |
|---|
| 444 |
`initial-major-mode' in your init file. *Note Init File::.) |
|---|
| 445 |
|
|---|
| 446 |
It is possible to specify files to be visited, Lisp files to be |
|---|
| 447 |
loaded, and functions to be called, by giving Emacs arguments in the |
|---|
| 448 |
shell command line. *Note Command Arguments::. But we don't recommend |
|---|
| 449 |
doing this. The feature exists mainly for compatibility with other |
|---|
| 450 |
editors. |
|---|
| 451 |
|
|---|
| 452 |
Many other editors are designed to be started afresh each time you |
|---|
| 453 |
want to edit. You edit one file and then exit the editor. The next |
|---|
| 454 |
time you want to edit either another file or the same one, you must run |
|---|
| 455 |
the editor again. With these editors, it makes sense to use a |
|---|
| 456 |
command-line argument to say which file to edit. |
|---|
| 457 |
|
|---|
| 458 |
But starting a new Emacs each time you want to edit a different file |
|---|
| 459 |
does not make sense. For one thing, this would be annoyingly slow. |
|---|
| 460 |
For another, this would fail to take advantage of Emacs's ability to |
|---|
| 461 |
visit more than one file in a single editing session. And it would |
|---|
| 462 |
lose the other accumulated context, such as the kill ring, registers, |
|---|
| 463 |
undo history, and mark ring. |
|---|
| 464 |
|
|---|
| 465 |
The recommended way to use GNU Emacs is to start it only once, just |
|---|
| 466 |
after you log in, and do all your editing in the same Emacs session. |
|---|
| 467 |
Each time you want to edit a different file, you visit it with the |
|---|
| 468 |
existing Emacs, which eventually comes to have many files in it ready |
|---|
| 469 |
for editing. Usually you do not kill the Emacs until you are about to |
|---|
| 470 |
log out. *Note Files::, for more information on visiting more than one |
|---|
| 471 |
file. |
|---|
| 472 |
|
|---|
| 473 |
|
|---|
| 474 |
File: emacs, Node: Exiting, Next: Basic, Prev: Entering Emacs, Up: Top |
|---|
| 475 |
|
|---|
| 476 |
Exiting Emacs |
|---|
| 477 |
============= |
|---|
| 478 |
|
|---|
| 479 |
There are two commands for exiting Emacs because there are two kinds |
|---|
| 480 |
of exiting: "suspending" Emacs and "killing" Emacs. |
|---|
| 481 |
|
|---|
| 482 |
"Suspending" means stopping Emacs temporarily and returning control |
|---|
| 483 |
to its parent process (usually a shell), allowing you to resume editing |
|---|
| 484 |
later in the same Emacs job, with the same buffers, same kill ring, |
|---|
| 485 |
same undo history, and so on. This is the usual way to exit. |
|---|
| 486 |
|
|---|
| 487 |
"Killing" Emacs means destroying the Emacs job. You can run Emacs |
|---|
| 488 |
again later, but you will get a fresh Emacs; there is no way to resume |
|---|
| 489 |
the same editing session after it has been killed. |
|---|
| 490 |
|
|---|
| 491 |
`C-z' |
|---|
| 492 |
Suspend Emacs (`suspend-emacs') or iconify a frame |
|---|
| 493 |
(`iconify-or-deiconify-frame'). |
|---|
| 494 |
|
|---|
| 495 |
`C-x C-c' |
|---|
| 496 |
Kill Emacs (`save-buffers-kill-emacs'). |
|---|
| 497 |
|
|---|
| 498 |
To suspend Emacs, type `C-z' (`suspend-emacs'). This takes you back |
|---|
| 499 |
to the shell from which you invoked Emacs. You can resume Emacs with |
|---|
| 500 |
the shell command `%emacs' in most common shells. |
|---|
| 501 |
|
|---|
| 502 |
On systems that do not support suspending programs, `C-z' starts an |
|---|
| 503 |
inferior shell that communicates directly with the terminal. Emacs |
|---|
| 504 |
waits until you exit the subshell. (The way to do that is probably |
|---|
| 505 |
with `C-d' or `exit', but it depends on which shell you use.) The only |
|---|
| 506 |
way on these systems to get back to the shell from which Emacs was run |
|---|
| 507 |
(to log out, for example) is to kill Emacs. |
|---|
| 508 |
|
|---|
| 509 |
Suspending also fails if you run Emacs under a shell that doesn't |
|---|
| 510 |
support suspending programs, even if the system itself does support it. |
|---|
| 511 |
In such a case, you can set the variable `cannot-suspend' to a |
|---|
| 512 |
non-`nil' value to force `C-z' to start an inferior shell. (One might |
|---|
| 513 |
also describe Emacs's parent shell as "inferior" for failing to support |
|---|
| 514 |
job control properly, but that is a matter of taste.) |
|---|
| 515 |
|
|---|
| 516 |
When Emacs communicates directly with an X server and creates its own |
|---|
| 517 |
dedicated X windows, `C-z' has a different meaning. Suspending an |
|---|
| 518 |
application that uses its own X windows is not meaningful or useful. |
|---|
| 519 |
Instead, `C-z' runs the command `iconify-or-deiconify-frame', which |
|---|
| 520 |
temporarily iconifies (or "minimizes") the selected Emacs frame (*note |
|---|
| 521 |
Frames::). Then you can use the window manager to get back to a shell |
|---|
| 522 |
window. |
|---|
| 523 |
|
|---|
| 524 |
To exit and kill Emacs, type `C-x C-c' (`save-buffers-kill-emacs'). |
|---|
| 525 |
A two-character key is used for this to make it harder to type by |
|---|
| 526 |
accident. This command first offers to save any modified file-visiting |
|---|
| 527 |
buffers. If you do not save them all, it asks for reconfirmation with |
|---|
| 528 |
`yes' before killing Emacs, since any changes not saved will be lost |
|---|
| 529 |
forever. Also, if any subprocesses are still running, `C-x C-c' asks |
|---|
| 530 |
for confirmation about them, since killing Emacs will also kill the |
|---|
| 531 |
subprocesses. |
|---|
| 532 |
|
|---|
| 533 |
If the value of the variable `confirm-kill-emacs' is non-`nil', `C-x |
|---|
| 534 |
C-c' assumes that its value is a predicate function, and calls that |
|---|
| 535 |
function. If the result is non-`nil', the session is killed, otherwise |
|---|
| 536 |
Emacs continues to run. One convenient function to use as the value of |
|---|
| 537 |
`confirm-kill-emacs' is the function `yes-or-no-p'. The default value |
|---|
| 538 |
of `confirm-kill-emacs' is `nil'. |
|---|
| 539 |
|
|---|
| 540 |
There is no way to resume an Emacs session once you have killed it. |
|---|
| 541 |
You can, however, arrange for Emacs to record certain session |
|---|
| 542 |
information when you kill it, such as which files are visited, so that |
|---|
| 543 |
the next time you start Emacs it will try to visit the same files and |
|---|
| 544 |
so on. *Note Saving Emacs Sessions::. |
|---|
| 545 |
|
|---|
| 546 |
The operating system usually listens for certain special characters |
|---|
| 547 |
whose meaning is to kill or suspend the program you are running. This |
|---|
| 548 |
operating system feature is turned off while you are in Emacs. The |
|---|
| 549 |
meanings of `C-z' and `C-x C-c' as keys in Emacs were inspired by the |
|---|
| 550 |
use of `C-z' and `C-c' on several operating systems as the characters |
|---|
| 551 |
for stopping or killing a program, but that is their only relationship |
|---|
| 552 |
with the operating system. You can customize these keys to run any |
|---|
| 553 |
commands of your choice (*note Keymaps::). |
|---|
| 554 |
|
|---|
| 555 |
|
|---|
| 556 |
File: emacs, Node: Basic, Next: Minibuffer, Prev: Exiting, Up: Top |
|---|
| 557 |
|
|---|
| 558 |
Basic Editing Commands |
|---|
| 559 |
********************** |
|---|
| 560 |
|
|---|
| 561 |
We now give the basics of how to enter text, make corrections, and |
|---|
| 562 |
save the text in a file. If this material is new to you, you might |
|---|
| 563 |
learn it more easily by running the Emacs learn-by-doing tutorial. To |
|---|
| 564 |
use the tutorial, run Emacs and type `Control-h t' |
|---|
| 565 |
(`help-with-tutorial'). |
|---|
| 566 |
|
|---|
| 567 |
To clear the screen and redisplay, type `C-l' (`recenter'). |
|---|
| 568 |
|
|---|
| 569 |
* Menu: |
|---|
| 570 |
|
|---|
| 571 |
|
|---|
| 572 |
* Inserting Text:: Inserting text by simply typing it. |
|---|
| 573 |
* Moving Point:: How to move the cursor to the place where you want to |
|---|
| 574 |
change something. |
|---|
| 575 |
* Erasing:: Deleting and killing text. |
|---|
| 576 |
* Undo:: Undoing recent changes in the text. |
|---|
| 577 |
* Files: Basic Files. Visiting, creating, and saving files. |
|---|
| 578 |
* Help: Basic Help. Asking what a character does. |
|---|
| 579 |
* Blank Lines:: Commands to make or delete blank lines. |
|---|
| 580 |
* Continuation Lines:: Lines too wide for the screen. |
|---|
| 581 |
* Position Info:: What page, line, row, or column is point on? |
|---|
| 582 |
* Arguments:: Numeric arguments for repeating a command. |
|---|
| 583 |
* Repeating:: A short-cut for repeating the previous command. |
|---|
| 584 |
|
|---|
| 585 |
|
|---|
| 586 |
File: emacs, Node: Inserting Text, Next: Moving Point, Up: Basic |
|---|
| 587 |
|
|---|
| 588 |
Inserting Text |
|---|
| 589 |
============== |
|---|
| 590 |
|
|---|
| 591 |
To insert printing characters into the text you are editing, just |
|---|
| 592 |
type them. This inserts the characters you type into the buffer at the |
|---|
| 593 |
cursor (that is, at "point"; *note Point::). The cursor moves forward, |
|---|
| 594 |
and any text after the cursor moves forward too. If the text in the |
|---|
| 595 |
buffer is `FOOBAR', with the cursor before the `B', then if you type |
|---|
| 596 |
`XX', you get `FOOXXBAR', with the cursor still before the `B'. |
|---|
| 597 |
|
|---|
| 598 |
To "delete" text you have just inserted, use the large key labeled |
|---|
| 599 |
<DEL>, <BACKSPACE> or <DELETE> which is a short distance above the |
|---|
| 600 |
<RET> or <ENTER> key. This is the key you normally use, outside Emacs, |
|---|
| 601 |
for erasing the last character that you typed. Regardless of the label |
|---|
| 602 |
on that key, Emacs thinks of it as <DEL>, and that's what we call it in |
|---|
| 603 |
this manual. |
|---|
| 604 |
|
|---|
| 605 |
The <DEL> key deletes the character _before_ the cursor. As a |
|---|
| 606 |
consequence, the cursor and all the characters after it move backwards. |
|---|
| 607 |
If you type a printing character and then type <DEL>, they cancel out. |
|---|
| 608 |
|
|---|
| 609 |
On most computers, Emacs recognizes automatically which key ought to |
|---|
| 610 |
be <DEL>, and sets it up that way. But in some cases, especially with |
|---|
| 611 |
text-only terminals, you will need to tell Emacs which key to use for |
|---|
| 612 |
that purpose. If the large key not far above the <RET> or <ENTER> key |
|---|
| 613 |
doesn't delete backwards, you need to do this. *Note DEL Does Not |
|---|
| 614 |
Delete::, for an explanation of how. |
|---|
| 615 |
|
|---|
| 616 |
Most PC keyboards have both a <BACKSPACE> key a short ways above |
|---|
| 617 |
<RET> or <ENTER>, and a <DELETE> key elsewhere. On these keyboards, |
|---|
| 618 |
Emacs supports when possible the usual convention that the <BACKSPACE> |
|---|
| 619 |
key deletes backwards (it is <DEL>), while the <DELETE> key deletes |
|---|
| 620 |
"forwards," deleting the character after point, the one underneath the |
|---|
| 621 |
cursor, like `C-d' (see below). |
|---|
| 622 |
|
|---|
| 623 |
To end a line and start typing a new one, type <RET>. This inserts |
|---|
| 624 |
a newline character in the buffer. If point is in the middle of a |
|---|
| 625 |
line, <RET> splits the line. Typing <DEL> when the cursor is at the |
|---|
| 626 |
beginning of a line deletes the preceding newline, thus joining the |
|---|
| 627 |
line with the preceding line. |
|---|
| 628 |
|
|---|
| 629 |
Emacs can split lines automatically when they become too long, if you |
|---|
| 630 |
turn on a special minor mode called "Auto Fill" mode. *Note Filling::, |
|---|
| 631 |
for how to use Auto Fill mode. |
|---|
| 632 |
|
|---|
| 633 |
If you prefer to have text characters replace (overwrite) existing |
|---|
| 634 |
text rather than shove it to the right, you can enable Overwrite mode, |
|---|
| 635 |
a minor mode. *Note Minor Modes::. |
|---|
| 636 |
|
|---|
| 637 |
Direct insertion works for printing characters and <SPC>, but other |
|---|
| 638 |
characters act as editing commands and do not insert themselves. If you |
|---|
| 639 |
need to insert a control character or a character whose code is above |
|---|
| 640 |
200 octal, you must "quote" it by typing the character `Control-q' |
|---|
| 641 |
(`quoted-insert') first. (This character's name is normally written |
|---|
| 642 |
`C-q' for short.) There are two ways to use `C-q': |
|---|
| 643 |
|
|---|
| 644 |
* `C-q' followed by any non-graphic character (even `C-g') inserts |
|---|
| 645 |
that character. |
|---|
| 646 |
|
|---|
| 647 |
* `C-q' followed by a sequence of octal digits inserts the character |
|---|
| 648 |
with the specified octal character code. You can use any number of |
|---|
| 649 |
octal digits; any non-digit terminates the sequence. If the |
|---|
| 650 |
terminating character is <RET>, it serves only to terminate the |
|---|
| 651 |
sequence. Any other non-digit terminates the sequence and then |
|---|
| 652 |
acts as normal input--thus, `C-q 1 0 1 B' inserts `AB'. |
|---|
| 653 |
|
|---|
| 654 |
The use of octal sequences is disabled in ordinary non-binary |
|---|
| 655 |
Overwrite mode, to give you a convenient way to insert a digit |
|---|
| 656 |
instead of overwriting with it. |
|---|
| 657 |
|
|---|
| 658 |
When multibyte characters are enabled, if you specify a code in the |
|---|
| 659 |
range 0200 through 0377 octal, `C-q' assumes that you intend to use |
|---|
| 660 |
some ISO 8859-N character set, and converts the specified code to the |
|---|
| 661 |
corresponding Emacs character code. *Note Enabling Multibyte::. You |
|---|
| 662 |
select _which_ of the ISO 8859 character sets to use through your |
|---|
| 663 |
choice of language environment (*note Language Environments::). |
|---|
| 664 |
|
|---|
| 665 |
To use decimal or hexadecimal instead of octal, set the variable |
|---|
| 666 |
`read-quoted-char-radix' to 10 or 16. If the radix is greater than 10, |
|---|
| 667 |
some letters starting with `a' serve as part of a character code, just |
|---|
| 668 |
like digits. |
|---|
| 669 |
|
|---|
| 670 |
A numeric argument to `C-q' specifies how many copies of the quoted |
|---|
| 671 |
character should be inserted (*note Arguments::). |
|---|
| 672 |
|
|---|
| 673 |
Customization information: <DEL> in most modes runs the command |
|---|
| 674 |
`delete-backward-char'; <RET> runs the command `newline', and |
|---|
| 675 |
self-inserting printing characters run the command `self-insert', which |
|---|
| 676 |
inserts whatever character was typed to invoke it. Some major modes |
|---|
| 677 |
rebind <DEL> to other commands. |
|---|
| 678 |
|
|---|
| 679 |
|
|---|
| 680 |
File: emacs, Node: Moving Point, Next: Erasing, Prev: Inserting Text, Up: Basic |
|---|
| 681 |
|
|---|
| 682 |
Changing the Location of Point |
|---|
| 683 |
============================== |
|---|
| 684 |
|
|---|
| 685 |
To do more than insert characters, you have to know how to move point |
|---|
| 686 |
(*note Point::). The simplest way to do this is with arrow keys, or by |
|---|
| 687 |
clicking the left mouse button where you want to move to. |
|---|
| 688 |
|
|---|
| 689 |
There are also control and meta characters for cursor motion. Some |
|---|
| 690 |
are equivalent to the arrow keys (these date back to the days before |
|---|
| 691 |
terminals had arrow keys, and are usable on terminals which don't have |
|---|
| 692 |
them). Others do more sophisticated things. |
|---|
| 693 |
|
|---|
| 694 |
`C-a' |
|---|
| 695 |
Move to the beginning of the line (`beginning-of-line'). |
|---|
| 696 |
|
|---|
| 697 |
`C-e' |
|---|
| 698 |
Move to the end of the line (`end-of-line'). |
|---|
| 699 |
|
|---|
| 700 |
`C-f' |
|---|
| 701 |
Move forward one character (`forward-char'). The right-arrow key |
|---|
| 702 |
does the same thing. |
|---|
| 703 |
|
|---|
| 704 |
`C-b' |
|---|
| 705 |
Move backward one character (`backward-char'). The left-arrow key |
|---|
| 706 |
has the same effect. |
|---|
| 707 |
|
|---|
| 708 |
`M-f' |
|---|
| 709 |
Move forward one word (`forward-word'). |
|---|
| 710 |
|
|---|
| 711 |
`M-b' |
|---|
| 712 |
Move backward one word (`backward-word'). |
|---|
| 713 |
|
|---|
| 714 |
`C-n' |
|---|
| 715 |
Move down one line, vertically (`next-line'). This command |
|---|
| 716 |
attempts to keep the horizontal position unchanged, so if you |
|---|
| 717 |
start in the middle of one line, you end in the middle of the |
|---|
| 718 |
next. The down-arrow key does the same thing. |
|---|
| 719 |
|
|---|
| 720 |
`C-p' |
|---|
| 721 |
Move up one line, vertically (`previous-line'). The up-arrow key |
|---|
| 722 |
has the same effect. |
|---|
| 723 |
|
|---|
| 724 |
`M-r' |
|---|
| 725 |
Move point to left margin, vertically centered in the window |
|---|
| 726 |
(`move-to-window-line'). Text does not move on the screen. |
|---|
| 727 |
|
|---|
| 728 |
A numeric argument says which screen line to place point on. It |
|---|
| 729 |
counts screen lines down from the top of the window (zero for the |
|---|
| 730 |
top line). A negative argument counts lines from the bottom (-1 |
|---|
| 731 |
for the bottom line). |
|---|
| 732 |
|
|---|
| 733 |
`M-<' |
|---|
| 734 |
Move to the top of the buffer (`beginning-of-buffer'). With |
|---|
| 735 |
numeric argument N, move to N/10 of the way from the top. *Note |
|---|
| 736 |
Arguments::, for more information on numeric arguments. |
|---|
| 737 |
|
|---|
| 738 |
`M->' |
|---|
| 739 |
Move to the end of the buffer (`end-of-buffer'). |
|---|
| 740 |
|
|---|
| 741 |
`C-v' |
|---|
| 742 |
Scroll the display one screen forward, and move point if necessary |
|---|
| 743 |
to put it on the screen (`scroll-up'). This doesn't always move |
|---|
| 744 |
point, but it is commonly used to do so. If your keyboard has a |
|---|
| 745 |
<PAGEDOWN> key, it does the same thing. |
|---|
| 746 |
|
|---|
| 747 |
Scrolling commands are further described in *Note Scrolling::. |
|---|
| 748 |
|
|---|
| 749 |
`M-v' |
|---|
| 750 |
Scroll one screen backward, and move point if necessary to put it |
|---|
| 751 |
on the screen (`scroll-down'). This doesn't always move point, but |
|---|
| 752 |
it is commonly used to do so. The <PAGEUP> key has the same |
|---|
| 753 |
effect. |
|---|
| 754 |
|
|---|
| 755 |
`M-x goto-char' |
|---|
| 756 |
Read a number N and move point to buffer position N. Position 1 |
|---|
| 757 |
is the beginning of the buffer. |
|---|
| 758 |
|
|---|
| 759 |
`M-x goto-line' |
|---|
| 760 |
Read a number N and move point to line number N. Line 1 is the |
|---|
| 761 |
beginning of the buffer. |
|---|
| 762 |
|
|---|
| 763 |
`C-x C-n' |
|---|
| 764 |
Use the current column of point as the "semipermanent goal column" |
|---|
| 765 |
for `C-n' and `C-p' (`set-goal-column'). Henceforth, those |
|---|
| 766 |
commands always move to this column in each line moved into, or as |
|---|
| 767 |
close as possible given the contents of the line. This goal |
|---|
| 768 |
column remains in effect until canceled. |
|---|
| 769 |
|
|---|
| 770 |
`C-u C-x C-n' |
|---|
| 771 |
Cancel the goal column. Henceforth, `C-n' and `C-p' once again |
|---|
| 772 |
try to stick to a fixed horizontal position, as usual. |
|---|
| 773 |
|
|---|
| 774 |
If you set the variable `track-eol' to a non-`nil' value, then `C-n' |
|---|
| 775 |
and `C-p', when starting at the end of the line, move to the end of |
|---|
| 776 |
another line. Normally, `track-eol' is `nil'. *Note Variables::, for |
|---|
| 777 |
how to set variables such as `track-eol'. |
|---|
| 778 |
|
|---|
| 779 |
`C-n' normally gets an error when you use it on the last line of the |
|---|
| 780 |
buffer (just as `C-p' gets an error on the first line). But if you set |
|---|
| 781 |
the variable `next-line-add-newlines' to a non-`nil' value, `C-n' on |
|---|
| 782 |
the last line of a buffer creates an additional line at the end and |
|---|
| 783 |
moves down onto it. |
|---|
| 784 |
|
|---|
| 785 |
|
|---|
| 786 |
File: emacs, Node: Erasing, Next: Undo, Prev: Moving Point, Up: Basic |
|---|
| 787 |
|
|---|
| 788 |
Erasing Text |
|---|
| 789 |
============ |
|---|
| 790 |
|
|---|
| 791 |
`<DEL>' |
|---|
| 792 |
Delete the character before point (`delete-backward-char'). |
|---|
| 793 |
|
|---|
| 794 |
`C-d' |
|---|
| 795 |
Delete the character after point (`delete-char'). |
|---|
| 796 |
|
|---|
| 797 |
`<DELETE>' |
|---|
| 798 |
`<BACKSPACE>' |
|---|
| 799 |
One of these keys, whichever is the large key above the <RET> or |
|---|
| 800 |
<ENTER> key, deletes the character before point, like <DEL>. If |
|---|
| 801 |
that is <BACKSPACE>, and your keyboard also has <DELETE>, then |
|---|
| 802 |
<DELETE> deletes forwards, like `C-d'. |
|---|
| 803 |
|
|---|
| 804 |
`C-k' |
|---|
| 805 |
Kill to the end of the line (`kill-line'). |
|---|
| 806 |
|
|---|
| 807 |
`M-d' |
|---|
| 808 |
Kill forward to the end of the next word (`kill-word'). |
|---|
| 809 |
|
|---|
| 810 |
`M-<DEL>' |
|---|
| 811 |
Kill back to the beginning of the previous word |
|---|
| 812 |
(`backward-kill-word'). |
|---|
| 813 |
|
|---|
| 814 |
You already know about the <DEL> key which deletes the character |
|---|
| 815 |
before point (that is, before the cursor). Another key, `Control-d' |
|---|
| 816 |
(`C-d' for short), deletes the character after point (that is, the |
|---|
| 817 |
character that the cursor is on). This shifts the rest of the text on |
|---|
| 818 |
the line to the left. If you type `C-d' at the end of a line, it joins |
|---|
| 819 |
together that line and the next line. |
|---|
| 820 |
|
|---|
| 821 |
To erase a larger amount of text, use the `C-k' key, which kills a |
|---|
| 822 |
line at a time. If you type `C-k' at the beginning or middle of a |
|---|
| 823 |
line, it kills all the text up to the end of the line. If you type |
|---|
| 824 |
`C-k' at the end of a line, it joins that line and the next line. |
|---|
| 825 |
|
|---|
| 826 |
*Note Killing::, for more flexible ways of killing text. |
|---|
| 827 |
|
|---|
| 828 |
|
|---|
| 829 |
File: emacs, Node: Undo, Next: Basic Files, Prev: Erasing, Up: Basic |
|---|
| 830 |
|
|---|
| 831 |
Undoing Changes |
|---|
| 832 |
=============== |
|---|
| 833 |
|
|---|
| 834 |
You can undo all the recent changes in the buffer text, up to a |
|---|
| 835 |
certain point. Each buffer records changes individually, and the undo |
|---|
| 836 |
command always applies to the current buffer. Usually each editing |
|---|
| 837 |
command makes a separate entry in the undo records, but some commands |
|---|
| 838 |
such as `query-replace' make many entries, and very simple commands |
|---|
| 839 |
such as self-inserting characters are often grouped to make undoing less |
|---|
| 840 |
tedious. |
|---|
| 841 |
|
|---|
| 842 |
`C-x u' |
|---|
| 843 |
Undo one batch of changes--usually, one command worth (`undo'). |
|---|
| 844 |
|
|---|
| 845 |
`C-_' |
|---|
| 846 |
The same. |
|---|
| 847 |
|
|---|
| 848 |
`C-u C-x u' |
|---|
| 849 |
Undo one batch of changes in the region. |
|---|
| 850 |
|
|---|
| 851 |
The command `C-x u' or `C-_' is how you undo. The first time you |
|---|
| 852 |
give this command, it undoes the last change. Point moves back to |
|---|
| 853 |
where it was before the command that made the change. |
|---|
| 854 |
|
|---|
| 855 |
Consecutive repetitions of `C-_' or `C-x u' undo earlier and earlier |
|---|
| 856 |
changes, back to the limit of the undo information available. If all |
|---|
| 857 |
recorded changes have already been undone, the undo command displays an |
|---|
| 858 |
error message and does nothing. |
|---|
| 859 |
|
|---|
| 860 |
Any command other than an undo command breaks the sequence of undo |
|---|
| 861 |
commands. Starting from that moment, the previous undo commands become |
|---|
| 862 |
ordinary changes that you can undo. Thus, to redo changes you have |
|---|
| 863 |
undone, type `C-f' or any other command that will harmlessly break the |
|---|
| 864 |
sequence of undoing, then type more undo commands. |
|---|
| 865 |
|
|---|
| 866 |
Ordinary undo applies to all changes made in the current buffer. You |
|---|
| 867 |
can also perform "selective undo", limited to the current region. To |
|---|
| 868 |
do this, specify the region you want, then run the `undo' command with |
|---|
| 869 |
a prefix argument (the value does not matter): `C-u C-x u' or `C-u |
|---|
| 870 |
C-_'. This undoes the most recent change in the region. To undo |
|---|
| 871 |
further changes in the same region, repeat the `undo' command (no |
|---|
| 872 |
prefix argument is needed). In Transient Mark mode, any use of `undo' |
|---|
| 873 |
when there is an active region performs selective undo; you do not need |
|---|
| 874 |
a prefix argument. |
|---|
| 875 |
|
|---|
| 876 |
If you notice that a buffer has been modified accidentally, the |
|---|
| 877 |
easiest way to recover is to type `C-_' repeatedly until the stars |
|---|
| 878 |
disappear from the front of the mode line. At this time, all the |
|---|
| 879 |
modifications you made have been canceled. Whenever an undo command |
|---|
| 880 |
makes the stars disappear from the mode line, it means that the buffer |
|---|
| 881 |
contents are the same as they were when the file was last read in or |
|---|
| 882 |
saved. |
|---|
| 883 |
|
|---|
| 884 |
If you do not remember whether you changed the buffer deliberately, |
|---|
| 885 |
type `C-_' once. When you see the last change you made undone, you |
|---|
| 886 |
will see whether it was an intentional change. If it was an accident, |
|---|
| 887 |
leave it undone. If it was deliberate, redo the change as described |
|---|
| 888 |
above. |
|---|
| 889 |
|
|---|
| 890 |
Not all buffers record undo information. Buffers whose names start |
|---|
| 891 |
with spaces don't; these buffers are used internally by Emacs and its |
|---|
| 892 |
extensions to hold text that users don't normally look at or edit. |
|---|
| 893 |
|
|---|
| 894 |
You cannot undo mere cursor motion; only changes in the buffer |
|---|
| 895 |
contents save undo information. However, some cursor motion commands |
|---|
| 896 |
set the mark, so if you use these commands from time to time, you can |
|---|
| 897 |
move back to the neighborhoods you have moved through by popping the |
|---|
| 898 |
mark ring (*note Mark Ring::). |
|---|
| 899 |
|
|---|
| 900 |
When the undo information for a buffer becomes too large, Emacs |
|---|
| 901 |
discards the oldest undo information from time to time (during garbage |
|---|
| 902 |
collection). You can specify how much undo information to keep by |
|---|
| 903 |
setting two variables: `undo-limit' and `undo-strong-limit'. Their |
|---|
| 904 |
values are expressed in units of bytes of space. |
|---|
| 905 |
|
|---|
| 906 |
The variable `undo-limit' sets a soft limit: Emacs keeps undo data |
|---|
| 907 |
for enough commands to reach this size, and perhaps exceed it, but does |
|---|
| 908 |
not keep data for any earlier commands beyond that. Its default value |
|---|
| 909 |
is 20000. The variable `undo-strong-limit' sets a stricter limit: the |
|---|
| 910 |
command which pushes the size past this amount is itself forgotten. |
|---|
| 911 |
Its default value is 30000. |
|---|
| 912 |
|
|---|
| 913 |
Regardless of the values of those variables, the most recent change |
|---|
| 914 |
is never discarded, so there is no danger that garbage collection |
|---|
| 915 |
occurring right after an unintentional large change might prevent you |
|---|
| 916 |
from undoing it. |
|---|
| 917 |
|
|---|
| 918 |
The reason the `undo' command has two keys, `C-x u' and `C-_', set |
|---|
| 919 |
up to run it is that it is worthy of a single-character key, but on |
|---|
| 920 |
some keyboards it is not obvious how to type `C-_'. `C-x u' is an |
|---|
| 921 |
alternative you can type straightforwardly on any terminal. |
|---|
| 922 |
|
|---|
| 923 |
|
|---|
| 924 |
File: emacs, Node: Basic Files, Next: Basic Help, Prev: Undo, Up: Basic |
|---|
| 925 |
|
|---|
| 926 |
Files |
|---|
| 927 |
===== |
|---|
| 928 |
|
|---|
| 929 |
The commands described above are sufficient for creating and altering |
|---|
| 930 |
text in an Emacs buffer; the more advanced Emacs commands just make |
|---|
| 931 |
things easier. But to keep any text permanently you must put it in a |
|---|
| 932 |
"file". Files are named units of text which are stored by the |
|---|
| 933 |
operating system for you to retrieve later by name. To look at or use |
|---|
| 934 |
the contents of a file in any way, including editing the file with |
|---|
| 935 |
Emacs, you must specify the file name. |
|---|
| 936 |
|
|---|
| 937 |
Consider a file named `/usr/rms/foo.c'. In Emacs, to begin editing |
|---|
| 938 |
this file, type |
|---|
| 939 |
|
|---|
| 940 |
C-x C-f /usr/rms/foo.c <RET> |
|---|
| 941 |
|
|---|
| 942 |
Here the file name is given as an "argument" to the command `C-x C-f' |
|---|
| 943 |
(`find-file'). That command uses the "minibuffer" to read the |
|---|
| 944 |
argument, and you type <RET> to terminate the argument (*note |
|---|
| 945 |
Minibuffer::). |
|---|
| 946 |
|
|---|
| 947 |
Emacs obeys the command by "visiting" the file: creating a buffer, |
|---|
| 948 |
copying the contents of the file into the buffer, and then displaying |
|---|
| 949 |
the buffer for you to edit. If you alter the text, you can "save" the |
|---|
| 950 |
new text in the file by typing `C-x C-s' (`save-buffer'). This makes |
|---|
| 951 |
the changes permanent by copying the altered buffer contents back into |
|---|
| 952 |
the file `/usr/rms/foo.c'. Until you save, the changes exist only |
|---|
| 953 |
inside Emacs, and the file `foo.c' is unaltered. |
|---|
| 954 |
|
|---|
| 955 |
To create a file, just visit the file with `C-x C-f' as if it |
|---|
| 956 |
already existed. This creates an empty buffer in which you can insert |
|---|
| 957 |
the text you want to put in the file. The file is actually created when |
|---|
| 958 |
you save this buffer with `C-x C-s'. |
|---|
| 959 |
|
|---|
| 960 |
Of course, there is a lot more to learn about using files. *Note |
|---|
| 961 |
Files::. |
|---|
| 962 |
|
|---|
| 963 |
|
|---|
| 964 |
File: emacs, Node: Basic Help, Next: Blank Lines, Prev: Basic Files, Up: Basic |
|---|
| 965 |
|
|---|
| 966 |
Help |
|---|
| 967 |
==== |
|---|
| 968 |
|
|---|
| 969 |
If you forget what a key does, you can find out with the Help |
|---|
| 970 |
character, which is `C-h' (or <F1>, which is an alias for `C-h'). Type |
|---|
| 971 |
`C-h k' followed by the key you want to know about; for example, `C-h k |
|---|
| 972 |
C-n' tells you all about what `C-n' does. `C-h' is a prefix key; `C-h |
|---|
| 973 |
k' is just one of its subcommands (the command `describe-key'). The |
|---|
| 974 |
other subcommands of `C-h' provide different kinds of help. Type `C-h' |
|---|
| 975 |
twice to get a description of all the help facilities. *Note Help::. |
|---|
| 976 |
|
|---|
| 977 |
|
|---|
| 978 |
File: emacs, Node: Blank Lines, Next: Continuation Lines, Prev: Basic Help, Up: Basic |
|---|
| 979 |
|
|---|
| 980 |
Blank Lines |
|---|
| 981 |
=========== |
|---|
| 982 |
|
|---|
| 983 |
Here are special commands and techniques for putting in and taking |
|---|
| 984 |
out blank lines. |
|---|
| 985 |
|
|---|
| 986 |
`C-o' |
|---|
| 987 |
Insert one or more blank lines after the cursor (`open-line'). |
|---|
| 988 |
|
|---|
| 989 |
`C-x C-o' |
|---|
| 990 |
Delete all but one of many consecutive blank lines |
|---|
| 991 |
(`delete-blank-lines'). |
|---|
| 992 |
|
|---|
| 993 |
When you want to insert a new line of text before an existing line, |
|---|
| 994 |
you can do it by typing the new line of text, followed by <RET>. |
|---|
| 995 |
However, it may be easier to see what you are doing if you first make a |
|---|
| 996 |
blank line and then insert the desired text into it. This is easy to do |
|---|
| 997 |
using the key `C-o' (`open-line'), which inserts a newline after point |
|---|
| 998 |
but leaves point in front of the newline. After `C-o', type the text |
|---|
| 999 |
for the new line. `C-o F O O' has the same effect as `F O O <RET>', |
|---|
| 1000 |
except for the final location of point. |
|---|
| 1001 |
|
|---|
| 1002 |
You can make several blank lines by typing `C-o' several times, or |
|---|
| 1003 |
by giving it a numeric argument to tell it how many blank lines to make. |
|---|
| 1004 |
*Note Arguments::, for how. If you have a fill prefix, then `C-o' |
|---|
| 1005 |
command inserts the fill prefix on the new line, when you use it at the |
|---|
| 1006 |
beginning of a line. *Note Fill Prefix::. |
|---|
| 1007 |
|
|---|
| 1008 |
The easy way to get rid of extra blank lines is with the command |
|---|
| 1009 |
`C-x C-o' (`delete-blank-lines'). `C-x C-o' in a run of several blank |
|---|
| 1010 |
lines deletes all but one of them. `C-x C-o' on a solitary blank line |
|---|
| 1011 |
deletes that blank line. When point is on a nonblank line, `C-x C-o' |
|---|
| 1012 |
deletes any blank lines following that nonblank line. |
|---|
| 1013 |
|
|---|
| 1014 |
|
|---|
| 1015 |
File: emacs, Node: Continuation Lines, Next: Position Info, Prev: Blank Lines, Up: Basic |
|---|
| 1016 |
|
|---|
| 1017 |
Continuation Lines |
|---|
| 1018 |
================== |
|---|
| 1019 |
|
|---|
| 1020 |
If you add too many characters to one line without breaking it with |
|---|
| 1021 |
<RET>, the line grows to occupy two (or more) lines on the screen. On |
|---|
| 1022 |
graphical displays, Emacs indicates line wrapping with small bent |
|---|
| 1023 |
arrows in the fringes to the left and right of the window. On |
|---|
| 1024 |
text-only terminals, Emacs displays a `\' character at the right margin |
|---|
| 1025 |
of a screen line if it is not the last in its text line. This `\' |
|---|
| 1026 |
character says that the following screen line is not really a distinct |
|---|
| 1027 |
line in the text, just a "continuation" of a line too long to fit the |
|---|
| 1028 |
screen. Continuation is also called "line wrapping". |
|---|
| 1029 |
|
|---|
| 1030 |
When line wrapping occurs before a character that is wider than one |
|---|
| 1031 |
column, some columns at the end of the previous screen line may be |
|---|
| 1032 |
"empty." In this case, Emacs displays additional `\' characters in the |
|---|
| 1033 |
"empty" columns, just before the `\' character that indicates |
|---|
| 1034 |
continuation. |
|---|
| 1035 |
|
|---|
| 1036 |
Sometimes it is nice to have Emacs insert newlines automatically when |
|---|
| 1037 |
a line gets too long. Continuation on the screen does not do that. Use |
|---|
| 1038 |
Auto Fill mode (*note Filling::) if that's what you want. |
|---|
| 1039 |
|
|---|
| 1040 |
As an alternative to continuation, Emacs can display long lines by |
|---|
| 1041 |
"truncation". This means that all the characters that do not fit in |
|---|
| 1042 |
the width of the screen or window do not appear at all. They remain in |
|---|
| 1043 |
the buffer, temporarily invisible. On terminals, `$' in the last |
|---|
| 1044 |
column informs you that the line has been truncated on the display. On |
|---|
| 1045 |
window systems, a small straight arrow in the fringe to the right of |
|---|
| 1046 |
the window indicates a truncated line. |
|---|
| 1047 |
|
|---|
| 1048 |
Truncation instead of continuation happens whenever horizontal |
|---|
| 1049 |
scrolling is in use, and optionally in all side-by-side windows (*note |
|---|
| 1050 |
Windows::). You can enable or disable truncation for a particular |
|---|
| 1051 |
buffer with the command `M-x toggle-truncate-lines'. |
|---|
| 1052 |
|
|---|
| 1053 |
*Note Display Custom::, for additional variables that affect how |
|---|
| 1054 |
text is displayed. |
|---|
| 1055 |
|
|---|