25829
|
1 @c This is part of the Emacs manual.
|
|
2 @c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
|
|
3 @c See file emacs.texi for copying conditions.
|
|
4 @node Basic, Minibuffer, Exiting, Top
|
|
5 @chapter Basic Editing Commands
|
|
6
|
|
7 @kindex C-h t
|
|
8 @findex help-with-tutorial
|
|
9 We now give the basics of how to enter text, make corrections, and
|
|
10 save the text in a file. If this material is new to you, you might
|
|
11 learn it more easily by running the Emacs learn-by-doing tutorial. To
|
|
12 use the tutorial, run Emacs and type @kbd{Control-h t}
|
|
13 (@code{help-with-tutorial}).
|
|
14
|
|
15 To clear the screen and redisplay, type @kbd{C-l} (@code{recenter}).
|
|
16
|
|
17 @menu
|
|
18
|
|
19 * Inserting Text:: Inserting text by simply typing it.
|
|
20 * Moving Point:: How to move the cursor to the place where you want to
|
|
21 change something.
|
|
22 * Erasing:: Deleting and killing text.
|
|
23 * Undo:: Undoing recent changes in the text.
|
|
24 * Files: Basic Files. Visiting, creating, and saving files.
|
|
25 * Help: Basic Help. Asking what a character does.
|
|
26 * Blank Lines:: Commands to make or delete blank lines.
|
|
27 * Continuation Lines:: Lines too wide for the screen.
|
|
28 * Position Info:: What page, line, row, or column is point on?
|
|
29 * Arguments:: Numeric arguments for repeating a command.
|
|
30 * Repeating:: A short-cut for repeating the previous command.
|
|
31 @end menu
|
|
32
|
|
33 @node Inserting Text
|
|
34 @section Inserting Text
|
|
35
|
|
36 @cindex insertion
|
|
37 @cindex graphic characters
|
|
38 To insert printing characters into the text you are editing, just type
|
|
39 them. This inserts the characters you type into the buffer at the
|
|
40 cursor (that is, at @dfn{point}; @pxref{Point}). The cursor moves
|
|
41 forward, and any text after the cursor moves forward too. If the text
|
|
42 in the buffer is @samp{FOOBAR}, with the cursor before the @samp{B},
|
|
43 then if you type @kbd{XX}, you get @samp{FOOXXBAR}, with the cursor
|
|
44 still before the @samp{B}.
|
|
45
|
|
46 To @dfn{delete} text you have just inserted, use @key{DEL}. @key{DEL}
|
|
47 deletes the character @emph{before} the cursor (not the one that the cursor
|
|
48 is on top of or under; that is the character @var{after} the cursor). The
|
|
49 cursor and all characters after it move backwards. Therefore, if you type
|
|
50 a printing character and then type @key{DEL}, they cancel out.
|
|
51
|
|
52 @kindex RET
|
|
53 @cindex newline
|
|
54 To end a line and start typing a new one, type @key{RET}. This
|
|
55 inserts a newline character in the buffer. If point is in the middle of
|
|
56 a line, @key{RET} splits the line. Typing @key{DEL} when the cursor is
|
|
57 at the beginning of a line deletes the preceding newline, thus joining
|
|
58 the line with the preceding line.
|
|
59
|
|
60 Emacs can split lines automatically when they become too long, if you
|
|
61 turn on a special minor mode called @dfn{Auto Fill} mode.
|
|
62 @xref{Filling}, for how to use Auto Fill mode.
|
|
63
|
|
64 If you prefer to have text characters replace (overwrite) existing
|
|
65 text rather than shove it to the right, you can enable Overwrite mode,
|
|
66 a minor mode. @xref{Minor Modes}.
|
|
67
|
|
68 @cindex quoting
|
|
69 @kindex C-q
|
|
70 @findex quoted-insert
|
|
71 Direct insertion works for printing characters and @key{SPC}, but other
|
|
72 characters act as editing commands and do not insert themselves. If you
|
|
73 need to insert a control character or a character whose code is above 200
|
|
74 octal, you must @dfn{quote} it by typing the character @kbd{Control-q}
|
|
75 (@code{quoted-insert}) first. (This character's name is normally written
|
|
76 @kbd{C-q} for short.) There are two ways to use @kbd{C-q}:@refill
|
|
77
|
|
78 @itemize @bullet
|
|
79 @item
|
|
80 @kbd{C-q} followed by any non-graphic character (even @kbd{C-g})
|
|
81 inserts that character.
|
|
82
|
|
83 @item
|
|
84 @kbd{C-q} followed by a sequence of octal digits inserts the character
|
|
85 with the specified octal character code. You can use any number of
|
|
86 octal digits; any non-digit terminates the sequence. If the terminating
|
|
87 character is @key{RET}, it serves only to terminate the sequence; any
|
|
88 other non-digit is itself used as input after terminating the sequence.
|
|
89 (The use of octal sequences is disabled in ordinary non-binary Overwrite
|
|
90 mode, to give you a convenient way to insert a digit instead of
|
|
91 overwriting with it.)
|
|
92 @end itemize
|
|
93
|
|
94 @noindent
|
|
95 When multibyte characters are enabled, octal codes 0200 through 0377 are
|
|
96 not valid as characters; if you specify a code in this range, @kbd{C-q}
|
|
97 assumes that you intend to use some ISO Latin-@var{n} character set, and
|
|
98 converts the specified code to the corresponding Emacs character code.
|
|
99 @xref{Enabling Multibyte}. You select @emph{which} ISO Latin character
|
|
100 set though your choice of language environment (@pxref{Language
|
|
101 Environments}).
|
|
102
|
|
103 @vindex read-quoted-char-radix
|
|
104 To use decimal or hexadecimal instead of octal, set the variable
|
|
105 @code{read-quoted-char-radix} to 10 or 16. If the radix is greater than
|
|
106 10, some letters starting with @kbd{a} serve as part of a character
|
|
107 code, just like digits.
|
|
108
|
|
109 A numeric argument to @kbd{C-q} specifies how many copies of the
|
|
110 quoted character should be inserted (@pxref{Arguments}).
|
|
111
|
|
112 @findex newline
|
|
113 @findex self-insert
|
|
114 Customization information: @key{DEL} in most modes runs the command
|
|
115 @code{delete-backward-char}; @key{RET} runs the command @code{newline}, and
|
|
116 self-inserting printing characters run the command @code{self-insert},
|
|
117 which inserts whatever character was typed to invoke it. Some major modes
|
|
118 rebind @key{DEL} to other commands.
|
|
119
|
|
120 @node Moving Point
|
|
121 @section Changing the Location of Point
|
|
122
|
|
123 @cindex arrow keys
|
|
124 @kindex LEFT
|
|
125 @kindex RIGHT
|
|
126 @kindex UP
|
|
127 @kindex DOWN
|
|
128 @cindex moving point
|
|
129 @cindex movement
|
|
130 @cindex cursor motion
|
|
131 @cindex moving the cursor
|
|
132 To do more than insert characters, you have to know how to move point
|
|
133 (@pxref{Point}). The simplest way to do this is with arrow keys, or by
|
|
134 clicking the left mouse button where you want to move to.
|
|
135
|
|
136 There are also control and meta characters for cursor motion. Some
|
|
137 are equivalent to the arrow keys (these date back to the days before
|
|
138 terminals had arrow keys, and are usable on terminals which don't have
|
|
139 them). Others do more sophisticated things.
|
|
140
|
|
141 @kindex C-a
|
|
142 @kindex C-e
|
|
143 @kindex C-f
|
|
144 @kindex C-b
|
|
145 @kindex C-n
|
|
146 @kindex C-p
|
|
147 @kindex M->
|
|
148 @kindex M-<
|
|
149 @kindex M-r
|
|
150 @findex beginning-of-line
|
|
151 @findex end-of-line
|
|
152 @findex forward-char
|
|
153 @findex backward-char
|
|
154 @findex next-line
|
|
155 @findex previous-line
|
|
156 @findex beginning-of-buffer
|
|
157 @findex end-of-buffer
|
|
158 @findex goto-char
|
|
159 @findex goto-line
|
|
160 @findex move-to-window-line
|
|
161 @table @kbd
|
|
162 @item C-a
|
|
163 Move to the beginning of the line (@code{beginning-of-line}).
|
|
164 @item C-e
|
|
165 Move to the end of the line (@code{end-of-line}).
|
|
166 @item C-f
|
|
167 Move forward one character (@code{forward-char}).
|
|
168 @item C-b
|
|
169 Move backward one character (@code{backward-char}).
|
|
170 @item M-f
|
|
171 Move forward one word (@code{forward-word}).
|
|
172 @item M-b
|
|
173 Move backward one word (@code{backward-word}).
|
|
174 @item C-n
|
|
175 Move down one line, vertically (@code{next-line}). This command
|
|
176 attempts to keep the horizontal position unchanged, so if you start in
|
|
177 the middle of one line, you end in the middle of the next. When on
|
|
178 the last line of text, @kbd{C-n} creates a new line and moves onto it.
|
|
179 @item C-p
|
|
180 Move up one line, vertically (@code{previous-line}).
|
|
181 @item M-r
|
|
182 Move point to left margin, vertically centered in the window
|
|
183 (@code{move-to-window-line}). Text does not move on the screen.
|
|
184
|
|
185 A numeric argument says which screen line to place point on. It counts
|
|
186 screen lines down from the top of the window (zero for the top line). A
|
|
187 negative argument counts lines from the bottom (@minus{}1 for the bottom
|
|
188 line).
|
|
189 @item M-<
|
|
190 Move to the top of the buffer (@code{beginning-of-buffer}). With
|
|
191 numeric argument @var{n}, move to @var{n}/10 of the way from the top.
|
|
192 @xref{Arguments}, for more information on numeric arguments.@refill
|
|
193 @item M->
|
|
194 Move to the end of the buffer (@code{end-of-buffer}).
|
|
195 @item M-x goto-char
|
|
196 Read a number @var{n} and move point to buffer position @var{n}.
|
|
197 Position 1 is the beginning of the buffer.
|
|
198 @item M-x goto-line
|
|
199 Read a number @var{n} and move point to line number @var{n}. Line 1
|
|
200 is the beginning of the buffer.
|
|
201 @item C-x C-n
|
|
202 @findex set-goal-column
|
|
203 @kindex C-x C-n
|
|
204 Use the current column of point as the @dfn{semipermanent goal column} for
|
|
205 @kbd{C-n} and @kbd{C-p} (@code{set-goal-column}). Henceforth, those
|
|
206 commands always move to this column in each line moved into, or as
|
|
207 close as possible given the contents of the line. This goal column remains
|
|
208 in effect until canceled.
|
|
209 @item C-u C-x C-n
|
|
210 Cancel the goal column. Henceforth, @kbd{C-n} and @kbd{C-p} once
|
|
211 again try to stick to a fixed horizontal position, as usual.
|
|
212 @end table
|
|
213
|
|
214 @vindex track-eol
|
|
215 If you set the variable @code{track-eol} to a non-@code{nil} value,
|
|
216 then @kbd{C-n} and @kbd{C-p} when at the end of the starting line move
|
|
217 to the end of another line. Normally, @code{track-eol} is @code{nil}.
|
|
218 @xref{Variables}, for how to set variables such as @code{track-eol}.
|
|
219
|
|
220 @vindex next-line-add-newlines
|
|
221 Normally, @kbd{C-n} on the last line of a buffer appends a newline to
|
|
222 it. If the variable @code{next-line-add-newlines} is @code{nil}, then
|
|
223 @kbd{C-n} gets an error instead (like @kbd{C-p} on the first line).
|
|
224
|
|
225 @node Erasing
|
|
226 @section Erasing Text
|
|
227
|
|
228 @table @kbd
|
|
229 @item @key{DEL}
|
|
230 Delete the character before point (@code{delete-backward-char}).
|
|
231 @item C-d
|
|
232 Delete the character after point (@code{delete-char}).
|
|
233 @item C-k
|
|
234 Kill to the end of the line (@code{kill-line}).
|
|
235 @item M-d
|
|
236 Kill forward to the end of the next word (@code{kill-word}).
|
|
237 @item M-@key{DEL}
|
|
238 Kill back to the beginning of the previous word
|
|
239 (@code{backward-kill-word}).
|
|
240 @end table
|
|
241
|
|
242 @cindex killing characters and lines
|
|
243 @cindex deleting characters and lines
|
|
244 @cindex erasing characters and lines
|
|
245 You already know about the @key{DEL} key which deletes the character
|
|
246 before point (that is, before the cursor). Another key, @kbd{Control-d}
|
|
247 (@kbd{C-d} for short), deletes the character after point (that is, the
|
|
248 character that the cursor is on). This shifts the rest of the text on
|
|
249 the line to the left. If you type @kbd{C-d} at the end of a line, it
|
|
250 joins together that line and the next line.
|
|
251
|
|
252 To erase a larger amount of text, use the @kbd{C-k} key, which kills a
|
|
253 line at a time. If you type @kbd{C-k} at the beginning or middle of a
|
|
254 line, it kills all the text up to the end of the line. If you type
|
|
255 @kbd{C-k} at the end of a line, it joins that line and the next line.
|
|
256
|
|
257 @xref{Killing}, for more flexible ways of killing text.
|
|
258
|
|
259 @node Undo
|
|
260 @section Undoing Changes
|
|
261 @cindex undo
|
|
262 @cindex changes, undoing
|
|
263
|
|
264 You can undo all the recent changes in the buffer text, up to a
|
|
265 certain point. Each buffer records changes individually, and the undo
|
|
266 command always applies to the current buffer. Usually each editing
|
|
267 command makes a separate entry in the undo records, but some commands
|
|
268 such as @code{query-replace} make many entries, and very simple commands
|
|
269 such as self-inserting characters are often grouped to make undoing less
|
|
270 tedious.
|
|
271
|
|
272 @table @kbd
|
|
273 @item C-x u
|
|
274 Undo one batch of changes---usually, one command worth (@code{undo}).
|
|
275 @item C-_
|
|
276 The same.
|
|
277 @item C-u C-x u
|
|
278 Undo one batch of changes in the region.
|
|
279 @end table
|
|
280
|
|
281 @kindex C-x u
|
|
282 @kindex C-_
|
|
283 @findex undo
|
|
284 The command @kbd{C-x u} or @kbd{C-_} is how you undo. The first time
|
|
285 you give this command, it undoes the last change. Point moves back to
|
|
286 where it was before the command that made the change.
|
|
287
|
|
288 Consecutive repetitions of @kbd{C-_} or @kbd{C-x u} undo earlier and
|
|
289 earlier changes, back to the limit of the undo information available.
|
|
290 If all recorded changes have already been undone, the undo command
|
|
291 prints an error message and does nothing.
|
|
292
|
|
293 Any command other than an undo command breaks the sequence of undo
|
|
294 commands. Starting from that moment, the previous undo commands become
|
|
295 ordinary changes that you can undo. Thus, to redo changes you have
|
|
296 undone, type @kbd{C-f} or any other command that will harmlessly break
|
|
297 the sequence of undoing, then type more undo commands.
|
|
298
|
|
299 @cindex selective undo
|
|
300 @kindex C-u C-x u
|
|
301 Ordinary undo applies to all changes made in the current buffer. You
|
|
302 can also perform @dfn{selective undo}, limited to the current region.
|
|
303 To do this, specify the region you want, then run the @code{undo}
|
|
304 command with a prefix argument (the value does not matter): @kbd{C-u C-x
|
|
305 u} or @kbd{C-u C-_}. This undoes the most recent change in the region.
|
|
306 To undo further changes in the same region, repeat the @code{undo}
|
|
307 command (no prefix argument is needed). In Transient Mark mode, any use
|
|
308 of @code{undo} when there is an active region performs selective undo;
|
|
309 you do not need a prefix argument.
|
|
310
|
|
311 If you notice that a buffer has been modified accidentally, the
|
|
312 easiest way to recover is to type @kbd{C-_} repeatedly until the stars
|
|
313 disappear from the front of the mode line. At this time, all the
|
|
314 modifications you made have been canceled. Whenever an undo command
|
|
315 makes the stars disappear from the mode line, it means that the buffer
|
|
316 contents are the same as they were when the file was last read in or
|
|
317 saved.
|
|
318
|
|
319 If you do not remember whether you changed the buffer deliberately,
|
|
320 type @kbd{C-_} once. When you see the last change you made undone, you
|
|
321 will see whether it was an intentional change. If it was an accident,
|
|
322 leave it undone. If it was deliberate, redo the change as described
|
|
323 above.
|
|
324
|
|
325 Not all buffers record undo information. Buffers whose names start with
|
|
326 spaces don't; these buffers are used internally by Emacs and its extensions
|
|
327 to hold text that users don't normally look at or edit.
|
|
328
|
|
329 You cannot undo mere cursor motion; only changes in the buffer
|
|
330 contents save undo information. However, some cursor motion commands
|
|
331 set the mark, so if you use these commands from time to time, you can
|
|
332 move back to the neighborhoods you have moved through by popping the
|
|
333 mark ring (@pxref{Mark Ring}).
|
|
334
|
|
335 @vindex undo-limit
|
|
336 @vindex undo-strong-limit
|
|
337 @cindex undo limit
|
|
338 When the undo information for a buffer becomes too large, Emacs
|
|
339 discards the oldest undo information from time to time (during garbage
|
|
340 collection). You can specify how much undo information to keep by
|
|
341 setting two variables: @code{undo-limit} and @code{undo-strong-limit}.
|
|
342 Their values are expressed in units of bytes of space.
|
|
343
|
|
344 The variable @code{undo-limit} sets a soft limit: Emacs keeps undo
|
|
345 data for enough commands to reach this size, and perhaps exceed it, but
|
|
346 does not keep data for any earlier commands beyond that. Its default
|
|
347 value is 20000. The variable @code{undo-strong-limit} sets a stricter
|
|
348 limit: the command which pushes the size past this amount is itself
|
|
349 forgotten. Its default value is 30000.
|
|
350
|
|
351 Regardless of the values of those variables, the most recent change is
|
|
352 never discarded, so there is no danger that garbage collection occurring
|
|
353 right after an unintentional large change might prevent you from undoing
|
|
354 it.
|
|
355
|
|
356 The reason the @code{undo} command has two keys, @kbd{C-x u} and
|
|
357 @kbd{C-_}, set up to run it is that it is worthy of a single-character
|
|
358 key, but on some keyboards it is not obvious how to type @kbd{C-_}.
|
|
359 @kbd{C-x u} is an alternative you can type straightforwardly on any
|
|
360 terminal.
|
|
361
|
|
362 @node Basic Files
|
|
363 @section Files
|
|
364
|
|
365 The commands described above are sufficient for creating and altering
|
|
366 text in an Emacs buffer; the more advanced Emacs commands just make
|
|
367 things easier. But to keep any text permanently you must put it in a
|
|
368 @dfn{file}. Files are named units of text which are stored by the
|
|
369 operating system for you to retrieve later by name. To look at or use
|
|
370 the contents of a file in any way, including editing the file with
|
|
371 Emacs, you must specify the file name.
|
|
372
|
|
373 Consider a file named @file{/usr/rms/foo.c}. In Emacs, to begin editing
|
|
374 this file, type
|
|
375
|
|
376 @example
|
|
377 C-x C-f /usr/rms/foo.c @key{RET}
|
|
378 @end example
|
|
379
|
|
380 @noindent
|
|
381 Here the file name is given as an @dfn{argument} to the command @kbd{C-x
|
|
382 C-f} (@code{find-file}). That command uses the @dfn{minibuffer} to
|
|
383 read the argument, and you type @key{RET} to terminate the argument
|
|
384 (@pxref{Minibuffer}).@refill
|
|
385
|
|
386 Emacs obeys the command by @dfn{visiting} the file: creating a buffer,
|
|
387 copying the contents of the file into the buffer, and then displaying
|
|
388 the buffer for you to edit. If you alter the text, you can @dfn{save}
|
|
389 the new text in the file by typing @kbd{C-x C-s} (@code{save-buffer}).
|
|
390 This makes the changes permanent by copying the altered buffer contents
|
|
391 back into the file @file{/usr/rms/foo.c}. Until you save, the changes
|
|
392 exist only inside Emacs, and the file @file{foo.c} is unaltered.
|
|
393
|
|
394 To create a file, just visit the file with @kbd{C-x C-f} as if it
|
|
395 already existed. This creates an empty buffer in which you can insert
|
|
396 the text you want to put in the file. The file is actually created when
|
|
397 you save this buffer with @kbd{C-x C-s}.
|
|
398
|
|
399 Of course, there is a lot more to learn about using files. @xref{Files}.
|
|
400
|
|
401 @node Basic Help
|
|
402 @section Help
|
|
403
|
|
404 @cindex getting help with keys
|
|
405 If you forget what a key does, you can find out with the Help
|
|
406 character, which is @kbd{C-h} (or @key{F1}, which is an alias for
|
|
407 @kbd{C-h}). Type @kbd{C-h k} followed by the key you want to know
|
|
408 about; for example, @kbd{C-h k C-n} tells you all about what @kbd{C-n}
|
|
409 does. @kbd{C-h} is a prefix key; @kbd{C-h k} is just one of its
|
|
410 subcommands (the command @code{describe-key}). The other subcommands of
|
|
411 @kbd{C-h} provide different kinds of help. Type @kbd{C-h} twice to get
|
|
412 a description of all the help facilities. @xref{Help}.@refill
|
|
413
|
|
414 @node Blank Lines
|
|
415 @section Blank Lines
|
|
416
|
|
417 @cindex inserting blank lines
|
|
418 @cindex deleting blank lines
|
|
419 Here are special commands and techniques for putting in and taking out
|
|
420 blank lines.
|
|
421
|
|
422 @c widecommands
|
|
423 @table @kbd
|
|
424 @item C-o
|
|
425 Insert one or more blank lines after the cursor (@code{open-line}).
|
|
426 @item C-x C-o
|
|
427 Delete all but one of many consecutive blank lines
|
|
428 (@code{delete-blank-lines}).
|
|
429 @end table
|
|
430
|
|
431 @kindex C-o
|
|
432 @kindex C-x C-o
|
|
433 @cindex blank lines
|
|
434 @findex open-line
|
|
435 @findex delete-blank-lines
|
|
436 When you want to insert a new line of text before an existing line, you
|
|
437 can do it by typing the new line of text, followed by @key{RET}.
|
|
438 However, it may be easier to see what you are doing if you first make a
|
|
439 blank line and then insert the desired text into it. This is easy to do
|
|
440 using the key @kbd{C-o} (@code{open-line}), which inserts a newline
|
|
441 after point but leaves point in front of the newline. After @kbd{C-o},
|
|
442 type the text for the new line. @kbd{C-o F O O} has the same effect as
|
|
443 @w{@kbd{F O O @key{RET}}}, except for the final location of point.
|
|
444
|
|
445 You can make several blank lines by typing @kbd{C-o} several times, or
|
|
446 by giving it a numeric argument to tell it how many blank lines to make.
|
|
447 @xref{Arguments}, for how. If you have a fill prefix, then @kbd{C-o}
|
|
448 command inserts the fill prefix on the new line, when you use it at the
|
|
449 beginning of a line. @xref{Fill Prefix}.
|
|
450
|
|
451 The easy way to get rid of extra blank lines is with the command
|
|
452 @kbd{C-x C-o} (@code{delete-blank-lines}). @kbd{C-x C-o} in a run of
|
|
453 several blank lines deletes all but one of them. @kbd{C-x C-o} on a
|
|
454 solitary blank line deletes that blank line. When point is on a
|
|
455 nonblank line, @kbd{C-x C-o} deletes any blank lines following that
|
|
456 nonblank line.
|
|
457
|
|
458 @node Continuation Lines
|
|
459 @section Continuation Lines
|
|
460
|
|
461 @cindex continuation line
|
|
462 @cindex wrapping
|
|
463 @cindex line wrapping
|
|
464 If you add too many characters to one line without breaking it with
|
|
465 @key{RET}, the line will grow to occupy two (or more) lines on the screen,
|
|
466 with a @samp{\} at the extreme right margin of all but the last of them.
|
|
467 The @samp{\} says that the following screen line is not really a distinct
|
|
468 line in the text, but just the @dfn{continuation} of a line too long to fit
|
|
469 the screen. Continuation is also called @dfn{line wrapping}.
|
|
470
|
|
471 Sometimes it is nice to have Emacs insert newlines automatically when
|
|
472 a line gets too long. Continuation on the screen does not do that. Use
|
|
473 Auto Fill mode (@pxref{Filling}) if that's what you want.
|
|
474
|
|
475 @vindex truncate-lines
|
|
476 @cindex truncation
|
|
477 As an alternative to continuation, Emacs can display long lines by
|
|
478 @dfn{truncation}. This means that all the characters that do not fit in
|
|
479 the width of the screen or window do not appear at all. They remain in
|
|
480 the buffer, temporarily invisible. @samp{$} is used in the last column
|
|
481 instead of @samp{\} to inform you that truncation is in effect.
|
|
482
|
|
483 Truncation instead of continuation happens whenever horizontal
|
|
484 scrolling is in use, and optionally in all side-by-side windows
|
|
485 (@pxref{Windows}). You can enable truncation for a particular buffer by
|
|
486 setting the variable @code{truncate-lines} to non-@code{nil} in that
|
|
487 buffer. (@xref{Variables}.) Altering the value of
|
|
488 @code{truncate-lines} makes it local to the current buffer; until that
|
|
489 time, the default value is in effect. The default is initially
|
|
490 @code{nil}. @xref{Locals}.
|
|
491
|
|
492 @xref{Display Vars}, for additional variables that affect how text is
|
|
493 displayed.
|
|
494
|
|
495 @node Position Info
|
|
496 @section Cursor Position Information
|
|
497
|
|
498 Here are commands to get information about the size and position of
|
|
499 parts of the buffer, and to count lines.
|
|
500
|
|
501 @table @kbd
|
|
502 @item M-x what-page
|
|
503 Print page number of point, and line number within page.
|
|
504 @item M-x what-line
|
|
505 Print line number of point in the buffer.
|
|
506 @item M-x line-number-mode
|
|
507 Toggle automatic display of current line number.
|
|
508 @item M-=
|
|
509 Print number of lines in the current region (@code{count-lines-region}).
|
|
510 @xref{Mark}, for information about the region.
|
|
511 @item C-x =
|
|
512 Print character code of character after point, character position of
|
|
513 point, and column of point (@code{what-cursor-position}).
|
|
514 @end table
|
|
515
|
|
516 @findex what-page
|
|
517 @findex what-line
|
|
518 @cindex line number commands
|
|
519 @cindex location of point
|
|
520 @cindex cursor location
|
|
521 @cindex point location
|
|
522 There are two commands for working with line numbers. @kbd{M-x
|
|
523 what-line} computes the current line number and displays it in the echo
|
|
524 area. To go to a given line by number, use @kbd{M-x goto-line}; it
|
|
525 prompts you for the number. These line numbers count from one at the
|
|
526 beginning of the buffer.
|
|
527
|
|
528 You can also see the current line number in the mode line; @xref{Mode
|
|
529 Line}. If you narrow the buffer, then the line number in the mode line
|
|
530 is relative to the accessible portion (@pxref{Narrowing}). By contrast,
|
|
531 @code{what-line} shows both the line number relative to the narrowed
|
|
532 region and the line number relative to the whole buffer.
|
|
533
|
|
534 By contrast, @kbd{M-x what-page} counts pages from the beginning of
|
|
535 the file, and counts lines within the page, printing both numbers.
|
|
536 @xref{Pages}.
|
|
537
|
|
538 @kindex M-=
|
|
539 @findex count-lines-region
|
|
540 While on this subject, we might as well mention @kbd{M-=} (@code{count-lines-region}),
|
|
541 which prints the number of lines in the region (@pxref{Mark}).
|
|
542 @xref{Pages}, for the command @kbd{C-x l} which counts the lines in the
|
|
543 current page.
|
|
544
|
|
545 @kindex C-x =
|
|
546 @findex what-cursor-position
|
|
547 The command @kbd{C-x =} (@code{what-cursor-position}) can be used to find out
|
|
548 the column that the cursor is in, and other miscellaneous information about
|
|
549 point. It prints a line in the echo area that looks like this:
|
|
550
|
|
551 @smallexample
|
|
552 Char: c (0143, 99, 0x63) point=21044 of 26883(78%) column 53
|
|
553 @end smallexample
|
|
554
|
|
555 @noindent
|
|
556 (In fact, this is the output produced when point is before the
|
|
557 @samp{column} in the example.)
|
|
558
|
|
559 The four values after @samp{Char:} describe the character that follows
|
|
560 point, first by showing it and then by giving its character code in
|
|
561 octal, decimal and hex. For a non-ASCII multibyte character, these are
|
|
562 followed by @samp{ext} and the character's representation, in hex, in
|
|
563 the buffer's coding system, if that coding system encodes the character
|
|
564 safely and with a single byte (@pxref{Coding Systems}). If the
|
|
565 character's encoding is longer than one byte, Emacs shows @samp{ext ...}.
|
|
566
|
|
567 @samp{point=} is followed by the position of point expressed as a character
|
|
568 count. The front of the buffer counts as position 1, one character later
|
|
569 as 2, and so on. The next, larger, number is the total number of characters
|
|
570 in the buffer. Afterward in parentheses comes the position expressed as a
|
|
571 percentage of the total size.
|
|
572
|
|
573 @samp{column} is followed by the horizontal position of point, in
|
|
574 columns from the left edge of the window.
|
|
575
|
|
576 If the buffer has been narrowed, making some of the text at the
|
|
577 beginning and the end temporarily inaccessible, @kbd{C-x =} prints
|
|
578 additional text describing the currently accessible range. For example, it
|
|
579 might display this:
|
|
580
|
|
581 @smallexample
|
|
582 Char: C (0103, 67, 0x43) point=252 of 889(28%) <231 - 599> column 0
|
|
583 @end smallexample
|
|
584
|
|
585 @noindent
|
|
586 where the two extra numbers give the smallest and largest character
|
|
587 position that point is allowed to assume. The characters between those
|
|
588 two positions are the accessible ones. @xref{Narrowing}.
|
|
589
|
|
590 If point is at the end of the buffer (or the end of the accessible
|
|
591 part), the @w{@kbd{C-x =}} output does not describe a character after
|
|
592 point. The output might look like this:
|
|
593
|
|
594 @smallexample
|
|
595 point=26957 of 26956(100%) column 0
|
|
596 @end smallexample
|
|
597
|
|
598 @w{@kbd{C-u C-x =}} displays additional information about a character,
|
|
599 in place of the buffer coordinates and column: the character set name
|
|
600 and the codes that identify the character within that character set;
|
|
601 ASCII characters are identified as belonging to the @code{ASCII}
|
|
602 character set. In addition, the full character encoding, even if it
|
|
603 takes more than a single byte, is shown after @samp{ext}. Here's an
|
|
604 example for a Latin-1 character A with a grave accent in a buffer whose
|
|
605 coding system is iso-2022-7bit@footnote{On terminals that support
|
|
606 Latin-1 characters, the character shown after @samp{Char:} is displayed
|
|
607 as the actual glyph of A with grave accent.}:
|
|
608
|
|
609 @example
|
|
610 Char: @`A (04300, 2240, 0x8c0, ext ESC , A @@) (latin-iso8859-1 64)
|
|
611 @end example
|
|
612
|
|
613 @node Arguments
|
|
614 @section Numeric Arguments
|
|
615 @cindex numeric arguments
|
|
616 @cindex prefix arguments
|
|
617 @cindex arguments, numeric
|
|
618 @cindex arguments, prefix
|
|
619
|
|
620 In mathematics and computer usage, the word @dfn{argument} means
|
|
621 ``data provided to a function or operation.'' You can give any Emacs
|
|
622 command a @dfn{numeric argument} (also called a @dfn{prefix argument}).
|
|
623 Some commands interpret the argument as a repetition count. For
|
|
624 example, @kbd{C-f} with an argument of ten moves forward ten characters
|
|
625 instead of one. With these commands, no argument is equivalent to an
|
|
626 argument of one. Negative arguments tell most such commands to move or
|
|
627 act in the opposite direction.
|
|
628
|
|
629 @kindex M-1
|
|
630 @kindex M-@t{-}
|
|
631 @findex digit-argument
|
|
632 @findex negative-argument
|
|
633 If your terminal keyboard has a @key{META} key, the easiest way to
|
|
634 specify a numeric argument is to type digits and/or a minus sign while
|
|
635 holding down the @key{META} key. For example,
|
|
636 @example
|
|
637 M-5 C-n
|
|
638 @end example
|
|
639 @noindent
|
|
640 would move down five lines. The characters @kbd{Meta-1}, @kbd{Meta-2},
|
|
641 and so on, as well as @kbd{Meta--}, do this because they are keys bound
|
|
642 to commands (@code{digit-argument} and @code{negative-argument}) that
|
|
643 are defined to contribute to an argument for the next command. Digits
|
|
644 and @kbd{-} modified with Control, or Control and Meta, also specify
|
|
645 numeric arguments.
|
|
646
|
|
647 @kindex C-u
|
|
648 @findex universal-argument
|
|
649 Another way of specifying an argument is to use the @kbd{C-u}
|
|
650 (@code{universal-argument}) command followed by the digits of the
|
|
651 argument. With @kbd{C-u}, you can type the argument digits without
|
|
652 holding down modifier keys; @kbd{C-u} works on all terminals. To type a
|
|
653 negative argument, type a minus sign after @kbd{C-u}. Just a minus sign
|
|
654 without digits normally means @minus{}1.
|
|
655
|
|
656 @kbd{C-u} followed by a character which is neither a digit nor a minus
|
|
657 sign has the special meaning of ``multiply by four.'' It multiplies the
|
|
658 argument for the next command by four. @kbd{C-u} twice multiplies it by
|
|
659 sixteen. Thus, @kbd{C-u C-u C-f} moves forward sixteen characters. This
|
|
660 is a good way to move forward ``fast,'' since it moves about 1/5 of a line
|
|
661 in the usual size screen. Other useful combinations are @kbd{C-u C-n},
|
|
662 @kbd{C-u C-u C-n} (move down a good fraction of a screen), @kbd{C-u C-u
|
|
663 C-o} (make ``a lot'' of blank lines), and @kbd{C-u C-k} (kill four
|
|
664 lines).@refill
|
|
665
|
|
666 Some commands care only about whether there is an argument, and not about
|
|
667 its value. For example, the command @kbd{M-q} (@code{fill-paragraph}) with
|
|
668 no argument fills text; with an argument, it justifies the text as well.
|
|
669 (@xref{Filling}, for more information on @kbd{M-q}.) Plain @kbd{C-u} is a
|
|
670 handy way of providing an argument for such commands.
|
|
671
|
|
672 Some commands use the value of the argument as a repeat count, but do
|
|
673 something peculiar when there is no argument. For example, the command
|
|
674 @kbd{C-k} (@code{kill-line}) with argument @var{n} kills @var{n} lines,
|
|
675 including their terminating newlines. But @kbd{C-k} with no argument is
|
|
676 special: it kills the text up to the next newline, or, if point is right at
|
|
677 the end of the line, it kills the newline itself. Thus, two @kbd{C-k}
|
|
678 commands with no arguments can kill a nonblank line, just like @kbd{C-k}
|
|
679 with an argument of one. (@xref{Killing}, for more information on
|
|
680 @kbd{C-k}.)@refill
|
|
681
|
|
682 A few commands treat a plain @kbd{C-u} differently from an ordinary
|
|
683 argument. A few others may treat an argument of just a minus sign
|
|
684 differently from an argument of @minus{}1. These unusual cases are
|
|
685 described when they come up; they are always for reasons of convenience
|
|
686 of use of the individual command.
|
|
687
|
|
688 You can use a numeric argument to insert multiple copies of a
|
|
689 character. This is straightforward unless the character is a digit; for
|
|
690 example, @kbd{C-u 6 4 a} inserts 64 copies of the character @samp{a}.
|
|
691 But this does not work for inserting digits; @kbd{C-u 6 4 1} specifies
|
|
692 an argument of 641, rather than inserting anything. To separate the
|
|
693 digit to insert from the argument, type another @kbd{C-u}; for example,
|
|
694 @kbd{C-u 6 4 C-u 1} does insert 64 copies of the character @samp{1}.
|
|
695
|
|
696 We use the term ``prefix argument'' as well as ``numeric argument'' to
|
|
697 emphasize that you type the argument before the command, and to
|
|
698 distinguish these arguments from minibuffer arguments that come after
|
|
699 the command.
|
|
700
|
|
701 @node Repeating
|
|
702 @section Repeating a Command
|
|
703 @cindex repeating a command
|
|
704
|
|
705 @kindex C-x z
|
|
706 @findex repeat
|
|
707 The command @kbd{C-x z} (@code{repeat}) provides another way to repeat
|
|
708 an Emacs command many times. This command repeats the previous Emacs
|
|
709 command, whatever that was. Repeating a command uses the same arguments
|
|
710 that were used before; it does not read new arguments each time.
|
|
711
|
|
712 To repeat the command more than once, type additional @kbd{z}'s: each
|
|
713 @kbd{z} repeats the command one more time. Repetition ends when you
|
|
714 type a character other than @kbd{z}, or press a mouse button.
|
|
715
|
|
716 For example, suppose you type @kbd{C-u 2 0 C-d} to delete 20
|
|
717 characters. You can repeat that command (including its argument) three
|
|
718 additional times, to delete a total of 80 characters, by typing @kbd{C-x
|
|
719 z z z}. The first @kbd{C-x z} repeats the command once, and each
|
|
720 subsequent @kbd{z} repeats it once again.
|
|
721
|