Replace `read-input' by `read-string'.
[emacs.git] / man / basic.texi
blobf45f87335fbb28f21c67f163dcc230c5f1f82986
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985,86,87,93,94,95,97,2000,2001 Free Software Foundation, Inc.
3 @c See file emacs.texi for copying conditions.
4 @node Basic, Minibuffer, Exiting, Top
5 @chapter Basic Editing Commands
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}).
15   To clear the screen and redisplay, type @kbd{C-l} (@code{recenter}).
17 @menu
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
33 @node Inserting Text
34 @section Inserting Text
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}.
46    To @dfn{delete} text you have just inserted, use the large key
47 labeled @key{DEL}, @key{BACKSPACE} or @key{DELETE} which is a short
48 distance above the @key{RET} or @key{ENTER} key.  This is the key you
49 normally use, outside Emacs, for erasing the last character that you
50 typed.  Regardless of the label on that key, Emacs thinks of it as
51 @key{DEL}, and that's what we call it in this manual.
53   The @key{DEL} key deletes the character @emph{before} the cursor.
54 As a consequence, the cursor and all the characters after it move
55 backwards.  If you type a printing character and then type @key{DEL},
56 they cancel out.
58   On most computers, Emacs recognizes automatically which key ought to
59 be @key{DEL}, and sets it up that way.  But in some cases, especially
60 with text-only terminals, you will need to tell Emacs which key to use
61 for that purpose.  If the large key not far above the @key{RET} or
62 @key{ENTER} key doesn't delete backwards, you need to do this.
63 @xref{DEL Does Not Delete}, for an explanation of how.
65   Most PC keyboards have both a @key{BACKSPACE} key a short ways above
66 @key{RET} or @key{ENTER}, and a @key{DELETE} key elsewhere.  On these
67 keyboards, Emacs supports when possible the usual convention that the
68 @key{BACKSPACE} key deletes backwards (it is @key{DEL}), while the
69 @key{DELETE} key deletes ``forwards,'' deleting the character after
70 point, the one underneath the cursor, like @kbd{C-d} (see below).
72 @kindex RET
73 @cindex newline
74    To end a line and start typing a new one, type @key{RET}.  This
75 inserts a newline character in the buffer.  If point is in the middle of
76 a line, the effect is to split the line.  Typing @key{DEL} when the cursor is
77 at the beginning of a line deletes the preceding newline, thus joining
78 the line with the preceding line.
80   Emacs can split lines automatically when they become too long, if you
81 turn on a special minor mode called @dfn{Auto Fill} mode.
82 @xref{Filling}, for how to use Auto Fill mode.
84   If you prefer to have text characters replace (overwrite) existing
85 text rather than shove it to the right, you can enable Overwrite mode,
86 a minor mode.  @xref{Minor Modes}.
88 @cindex quoting
89 @kindex C-q
90 @findex quoted-insert
91   Direct insertion works for printing characters and @key{SPC}, but other
92 characters act as editing commands and do not insert themselves.  If you
93 need to insert a control character or a character whose code is above 200
94 octal, you must @dfn{quote} it by typing the character @kbd{Control-q}
95 (@code{quoted-insert}) first.  (This character's name is normally written
96 @kbd{C-q} for short.)  There are two ways to use @kbd{C-q}:@refill
98 @itemize @bullet
99 @item
100 @kbd{C-q} followed by any non-graphic character (even @kbd{C-g})
101 inserts that character.
103 @item
104 @kbd{C-q} followed by a sequence of octal digits inserts the character
105 with the specified octal character code.  You can use any number of
106 octal digits; any non-digit terminates the sequence.  If the
107 terminating character is @key{RET}, it serves only to terminate the
108 sequence.  Any other non-digit terminates the sequence and then acts
109 as normal input---thus, @kbd{C-q 1 0 1 B} inserts @samp{AB}.
111 The use of octal sequences is disabled in ordinary non-binary
112 Overwrite mode, to give you a convenient way to insert a digit instead
113 of overwriting with it.
114 @end itemize
116 @cindex 8-bit character codes
117 @noindent
118 When multibyte characters are enabled, if you specify a code in the
119 range 0200 through 0377 octal, @kbd{C-q} assumes that you intend to
120 use some ISO 8859-@var{n} character set, and converts the specified
121 code to the corresponding Emacs character code.  @xref{Enabling
122 Multibyte}.  You select @emph{which} of the ISO 8859 character sets to
123 use through your choice of language environment (@pxref{Language
124 Environments}).
126 @vindex read-quoted-char-radix
127 To use decimal or hexadecimal instead of octal, set the variable
128 @code{read-quoted-char-radix} to 10 or 16.  If the radix is greater than
129 10, some letters starting with @kbd{a} serve as part of a character
130 code, just like digits.
132 A numeric argument to @kbd{C-q} specifies how many copies of the
133 quoted character should be inserted (@pxref{Arguments}).
135 @findex newline
136 @findex self-insert
137   Customization information: @key{DEL} in most modes runs the command
138 @code{delete-backward-char}; @key{RET} runs the command @code{newline}, and
139 self-inserting printing characters run the command @code{self-insert},
140 which inserts whatever character was typed to invoke it.  Some major modes
141 rebind @key{DEL} to other commands.
143 @node Moving Point
144 @section Changing the Location of Point
146 @cindex arrow keys
147 @cindex moving point
148 @cindex movement
149 @cindex cursor motion
150 @cindex moving the cursor
151   To do more than insert characters, you have to know how to move point
152 (@pxref{Point}).  The simplest way to do this is with arrow keys, or by
153 clicking the left mouse button where you want to move to.
155   There are also control and meta characters for cursor motion.  Some
156 are equivalent to the arrow keys (these date back to the days before
157 terminals had arrow keys, and are usable on terminals which don't have
158 them).  Others do more sophisticated things.
160 @kindex C-a
161 @kindex C-e
162 @kindex C-f
163 @kindex C-b
164 @kindex C-n
165 @kindex C-p
166 @kindex M->
167 @kindex M-<
168 @kindex M-r
169 @kindex LEFT
170 @kindex RIGHT
171 @kindex UP
172 @kindex DOWN
173 @findex move-beginning-of-line
174 @findex move-end-of-line
175 @findex forward-char
176 @findex backward-char
177 @findex next-line
178 @findex previous-line
179 @findex beginning-of-buffer
180 @findex end-of-buffer
181 @findex goto-char
182 @findex goto-line
183 @findex move-to-window-line
184 @table @kbd
185 @item C-a
186 Move to the beginning of the line (@code{move-beginning-of-line}).
187 @item C-e
188 Move to the end of the line (@code{move-end-of-line}).
189 @item C-f
190 Move forward one character (@code{forward-char}).  The right-arrow key
191 does the same thing.
192 @item C-b
193 Move backward one character (@code{backward-char}).  The left-arrow
194 key has the same effect.
195 @item M-f
196 Move forward one word (@code{forward-word}).
197 @item M-b
198 Move backward one word (@code{backward-word}).
199 @item C-n
200 Move down one line, vertically (@code{next-line}).  This command
201 attempts to keep the horizontal position unchanged, so if you start in
202 the middle of one line, you end in the middle of the next.  The
203 down-arrow key does the same thing.
204 @item C-p
205 Move up one line, vertically (@code{previous-line}).  The up-arrow key
206 has the same effect.
207 @item M-r
208 Move point to left margin, vertically centered in the window
209 (@code{move-to-window-line}).  Text does not move on the screen.
211 A numeric argument says which screen line to place point on.  It counts
212 screen lines down from the top of the window (zero for the top line).  A
213 negative argument counts lines from the bottom (@minus{}1 for the bottom
214 line).
215 @item M-<
216 Move to the top of the buffer (@code{beginning-of-buffer}).  With
217 numeric argument @var{n}, move to @var{n}/10 of the way from the top.
218 @xref{Arguments}, for more information on numeric arguments.@refill
219 @item M->
220 Move to the end of the buffer (@code{end-of-buffer}).
221 @item C-v
222 @itemx @key{PAGEDOWN}
223 @itemx @key{PRIOR}
224 Scroll the display one screen forward, and move point if necessary to
225 put it on the screen (@code{scroll-up}).  This doesn't always move
226 point, but it is commonly used to do so.  If your keyboard has a
227 @key{PAGEDOWN} or @key{PRIOR} key, it does the same thing.
229 Scrolling commands are further described in @ref{Scrolling}.
230 @item M-v
231 @itemx @key{PAGEUP}
232 @itemx @key{NEXT}
233 Scroll one screen backward, and move point if necessary to put it on
234 the screen (@code{scroll-down}).  This doesn't always move point, but
235 it is commonly used to do so.  If your keyboard has a @key{PAGEUP} or
236 @key{NEXT} key, it does the same thing.
237 @item M-x goto-char
238 Read a number @var{n} and move point to buffer position @var{n}.
239 Position 1 is the beginning of the buffer.
240 @item M-g M-g
241 @itemx M-g g
242 @itemx M-x goto-line
243 Read a number @var{n} and move point to line number @var{n}.  Line 1
244 is the beginning of the buffer.
245 @item C-x C-n
246 @findex set-goal-column
247 @kindex C-x C-n
248 Use the current column of point as the @dfn{semipermanent goal column} for
249 @kbd{C-n} and @kbd{C-p} (@code{set-goal-column}).  Henceforth, those
250 commands always move to this column in each line moved into, or as
251 close as possible given the contents of the line.  This goal column remains
252 in effect until canceled.
253 @item C-u C-x C-n
254 Cancel the goal column.  Henceforth, @kbd{C-n} and @kbd{C-p} once
255 again try to stick to a fixed horizontal position, as usual.
256 @end table
258 @vindex track-eol
259   If you set the variable @code{track-eol} to a non-@code{nil} value,
260 then @kbd{C-n} and @kbd{C-p}, when starting at the end of the line, move
261 to the end of another line.  Normally, @code{track-eol} is @code{nil}.
262 @xref{Variables}, for how to set variables such as @code{track-eol}.
264 @vindex next-line-add-newlines
265   @kbd{C-n} normally stops at the end of the buffer when you use it on
266 the last line of the buffer.  But if you set the variable
267 @code{next-line-add-newlines} to a non-@code{nil} value, @kbd{C-n} on
268 the last line of a buffer creates an additional line at the end and
269 moves down onto it.
271 @node Erasing
272 @section Erasing Text
274 @table @kbd
275 @item @key{DEL}
276 Delete the character before point (@code{delete-backward-char}).
277 @item C-d
278 Delete the character after point (@code{delete-char}).
279 @item @key{DELETE}
280 @itemx @key{BACKSPACE}
281 One of these keys, whichever is the large key above the @key{RET} or
282 @key{ENTER} key, deletes the character before point, like @key{DEL}.
283 If that is @key{BACKSPACE}, and your keyboard also has @key{DELETE},
284 then @key{DELETE} deletes forwards, like @kbd{C-d}.
285 @item C-k
286 Kill to the end of the line (@code{kill-line}).
287 @item M-d
288 Kill forward to the end of the next word (@code{kill-word}).
289 @item M-@key{DEL}
290 Kill back to the beginning of the previous word
291 (@code{backward-kill-word}).
292 @end table
294 @cindex killing characters and lines
295 @cindex deleting characters and lines
296 @cindex erasing characters and lines
297   You already know about the @key{DEL} key which deletes the character
298 before point (that is, before the cursor).  Another key, @kbd{Control-d}
299 (@kbd{C-d} for short), deletes the character after point (that is, the
300 character that the cursor is on).  This shifts the rest of the text on
301 the line to the left.  If you type @kbd{C-d} at the end of a line, it
302 joins together that line and the next line.
304   To erase a larger amount of text, use the @kbd{C-k} key, which kills a
305 line at a time.  If you type @kbd{C-k} at the beginning or middle of a
306 line, it kills all the text up to the end of the line.  If you type
307 @kbd{C-k} at the end of a line, it joins that line and the next line.
309   @xref{Killing}, for more flexible ways of killing text.
311 @node Undo
312 @section Undoing Changes
313 @cindex undo
314 @cindex changes, undoing
316   You can undo all the recent changes in the buffer text, up to a
317 certain point.  Each buffer records changes individually, and the undo
318 command always applies to the current buffer.  Usually each editing
319 command makes a separate entry in the undo records, but some commands
320 such as @code{query-replace} make many entries, and very simple commands
321 such as self-inserting characters are often grouped to make undoing less
322 tedious.
324 @table @kbd
325 @item C-x u
326 Undo one batch of changes---usually, one command worth (@code{undo}).
327 @item C-_
328 @itemx C-/
329 The same.
330 @item C-u C-x u
331 Undo one batch of changes in the region.
332 @end table
334 @kindex C-x u
335 @kindex C-_
336 @kindex C-/
337 @findex undo
338   The command @kbd{C-x u} (or @kbd{C-_} or @kbd{C-/}) is how you undo.
339 The first time you give this command, it undoes the last change.
340 Point moves back to where it was before the command that made the
341 change.
343   Consecutive repetitions of @kbd{C-_} or @kbd{C-x u} undo earlier and
344 earlier changes, back to the limit of the undo information available.
345 If all recorded changes have already been undone, the undo command
346 displays an error message and does nothing.
348 @findex undo-only
349   Any command other than an undo command breaks the sequence of undo
350 commands.  Starting from that moment, the previous undo commands become
351 ordinary changes that you can undo.  Thus, to redo changes you have
352 undone, type @kbd{C-f} or any other command that will harmlessly break
353 the sequence of undoing, then type more undo commands.  On the other
354 hand, if you want to ignore previous undo commands, use @kbd{M-x
355 undo-only}.  This is like @code{undo}, but will not redo changes
356 you have just undone.
358 @cindex selective undo
359 @kindex C-u C-x u
360   Ordinary undo applies to all changes made in the current buffer.  You
361 can also perform @dfn{selective undo}, limited to the current region
362 (@pxref{Mark}).
363 To do this, specify the region you want, then run the @code{undo}
364 command with a prefix argument (the value does not matter): @kbd{C-u C-x
365 u} or @kbd{C-u C-_}.  This undoes the most recent change in the region.
366 To undo further changes in the same region, repeat the @code{undo}
367 command (no prefix argument is needed).  In Transient Mark mode
368 (@pxref{Transient Mark}), any use of @code{undo} when there is an
369 active region performs selective undo; you do not need a prefix
370 argument.
372   If you notice that a buffer has been modified accidentally, the
373 easiest way to recover is to type @kbd{C-_} repeatedly until the stars
374 disappear from the front of the mode line.  At this time, all the
375 modifications you made have been canceled.  Whenever an undo command
376 makes the stars disappear from the mode line, it means that the buffer
377 contents are the same as they were when the file was last read in or
378 saved.
380   If you do not remember whether you changed the buffer deliberately,
381 type @kbd{C-_} once.  When you see the last change you made undone, you
382 will see whether it was an intentional change.  If it was an accident,
383 leave it undone.  If it was deliberate, redo the change as described
384 above.
386   Not all buffers record undo information.  Buffers whose names start with
387 spaces don't; these buffers are used internally by Emacs and its extensions
388 to hold text that users don't normally look at or edit.
390   You cannot undo mere cursor motion; only changes in the buffer
391 contents save undo information.  However, some cursor motion commands
392 set the mark, so if you use these commands from time to time, you can
393 move back to the neighborhoods you have moved through by popping the
394 mark ring (@pxref{Mark Ring}).
396 @vindex undo-limit
397 @vindex undo-strong-limit
398 @vindex undo-outer-limit
399 @cindex undo limit
400   When the undo information for a buffer becomes too large, Emacs
401 discards the oldest undo information from time to time (during garbage
402 collection).  You can specify how much undo information to keep by
403 setting three variables: @code{undo-limit}, @code{undo-strong-limit},
404 and @code{undo-outer-limit}.  Their values are expressed in units of
405 bytes of space.
407   The variable @code{undo-limit} sets a soft limit: Emacs keeps undo
408 data for enough commands to reach this size, and perhaps exceed it,
409 but does not keep data for any earlier commands beyond that.  Its
410 default value is 20000.  The variable @code{undo-strong-limit} sets a
411 stricter limit: a previous command (not the most recent one) which
412 pushes the size past this amount is itself forgotten.  The default
413 value of @code{undo-strong-limit} is 30000.
415   Regardless of the values of those variables, the most recent change
416 is never discarded unless it gets bigger than @code{undo-outer-limit}
417 (normally 3,000,000).  At that point, Emacs discards the undo data and
418 warns you about it.  This is the only situation in which you cannot
419 undo the last command.  If this happens, you can increase the value of
420 @code{undo-outer-limit} to make it even less likely to happen in the
421 future.  But if you didn't expect the command to create such large
422 undo data, then it is probably a bug and you should report it.
423 @xref{Bugs,, Reporting Bugs}.
425   The reason the @code{undo} command has three key bindings, @kbd{C-x
426 u}, @kbd{C-_} and @kbd{C-/}, is that it is worthy of a
427 single-character key, but @kbd{C-x u} is more straightforward for
428 beginners to type.
430 @node Basic Files
431 @section Files
433   The commands described above are sufficient for creating and altering
434 text in an Emacs buffer; the more advanced Emacs commands just make
435 things easier.  But to keep any text permanently you must put it in a
436 @dfn{file}.  Files are named units of text which are stored by the
437 operating system for you to retrieve later by name.  To look at or use
438 the contents of a file in any way, including editing the file with
439 Emacs, you must specify the file name.
441   Consider a file named @file{/usr/rms/foo.c}.  In Emacs, to begin editing
442 this file, type
444 @example
445 C-x C-f /usr/rms/foo.c @key{RET}
446 @end example
448 @noindent
449 Here the file name is given as an @dfn{argument} to the command @kbd{C-x
450 C-f} (@code{find-file}).  That command uses the @dfn{minibuffer} to
451 read the argument, and you type @key{RET} to terminate the argument
452 (@pxref{Minibuffer}).@refill
454   Emacs obeys the command by @dfn{visiting} the file: creating a buffer,
455 copying the contents of the file into the buffer, and then displaying
456 the buffer for you to edit.  If you alter the text, you can @dfn{save}
457 the new text in the file by typing @kbd{C-x C-s} (@code{save-buffer}).
458 This makes the changes permanent by copying the altered buffer contents
459 back into the file @file{/usr/rms/foo.c}.  Until you save, the changes
460 exist only inside Emacs, and the file @file{foo.c} is unaltered.
462   To create a file, just visit the file with @kbd{C-x C-f} as if it
463 already existed.  This creates an empty buffer in which you can insert
464 the text you want to put in the file.  The file is actually created when
465 you save this buffer with @kbd{C-x C-s}.
467   Of course, there is a lot more to learn about using files.  @xref{Files}.
469 @node Basic Help
470 @section Help
472 @cindex getting help with keys
473   If you forget what a key does, you can find out with the Help
474 character, which is @kbd{C-h} (or @key{F1}, which is an alias for
475 @kbd{C-h}).  Type @kbd{C-h k} followed by the key you want to know
476 about; for example, @kbd{C-h k C-n} tells you all about what @kbd{C-n}
477 does.  @kbd{C-h} is a prefix key; @kbd{C-h k} is just one of its
478 subcommands (the command @code{describe-key}).  The other subcommands of
479 @kbd{C-h} provide different kinds of help.  Type @kbd{C-h} twice to get
480 a description of all the help facilities.  @xref{Help}.@refill
482 @node Blank Lines
483 @section Blank Lines
485 @cindex inserting blank lines
486 @cindex deleting blank lines
487   Here are special commands and techniques for putting in and taking out
488 blank lines.
490 @table @kbd
491 @item C-o
492 Insert one or more blank lines after the cursor (@code{open-line}).
493 @item C-x C-o
494 Delete all but one of many consecutive blank lines
495 (@code{delete-blank-lines}).
496 @end table
498 @kindex C-o
499 @kindex C-x C-o
500 @cindex blank lines
501 @findex open-line
502 @findex delete-blank-lines
503   When you want to insert a new line of text before an existing line, you
504 can do it by typing the new line of text, followed by @key{RET}.
505 However, it may be easier to see what you are doing if you first make a
506 blank line and then insert the desired text into it.  This is easy to do
507 using the key @kbd{C-o} (@code{open-line}), which inserts a newline
508 after point but leaves point in front of the newline.  After @kbd{C-o},
509 type the text for the new line.  @kbd{C-o F O O} has the same effect as
510 @w{@kbd{F O O @key{RET}}}, except for the final location of point.
512   You can make several blank lines by typing @kbd{C-o} several times, or
513 by giving it a numeric argument to tell it how many blank lines to make.
514 @xref{Arguments}, for how.  If you have a fill prefix, the @kbd{C-o}
515 command inserts the fill prefix on the new line, when you use it at the
516 beginning of a line.  @xref{Fill Prefix}.
518   The easy way to get rid of extra blank lines is with the command
519 @kbd{C-x C-o} (@code{delete-blank-lines}).  @kbd{C-x C-o} in a run of
520 several blank lines deletes all but one of them.  @kbd{C-x C-o} on a
521 solitary blank line deletes that blank line.  When point is on a
522 nonblank line, @kbd{C-x C-o} deletes any blank lines following that
523 nonblank line.
525 @node Continuation Lines
526 @section Continuation Lines
528 @cindex continuation line
529 @cindex wrapping
530 @cindex line wrapping
531 @cindex fringes, and continuation lines
532   If you add too many characters to one line without breaking it with
533 @key{RET}, the line grows to occupy two (or more) lines on the screen.
534 On graphical displays, Emacs indicates line wrapping with small bent
535 arrows in the fringes to the left and right of the window.  On
536 text-only terminals, Emacs displays a @samp{\} character at the right
537 margin of a screen line if it is not the last in its text line.  This
538 @samp{\} character says that the following screen line is not really a
539 distinct line in the text, just a @dfn{continuation} of a line too
540 long to fit the screen.  Continuation is also called @dfn{line
541 wrapping}.
543   When line wrapping occurs before a character that is wider than one
544 column, some columns at the end of the previous screen line may be
545 ``empty.''  In this case, Emacs displays additional @samp{\}
546 characters in the ``empty'' columns, just before the @samp{\}
547 character that indicates continuation.
549   Sometimes it is nice to have Emacs insert newlines automatically when
550 a line gets too long.  Continuation on the screen does not do that.  Use
551 Auto Fill mode (@pxref{Filling}) if that's what you want.
553 @cindex truncation
554 @cindex line truncation, and fringes
555   As an alternative to continuation, Emacs can display long lines by
556 @dfn{truncation}.  This means that all the characters that do not fit
557 in the width of the screen or window do not appear at all.  @samp{$}
558 in the last column or a small straight arrow in the fringe to the
559 right of the window indicates a truncated line.
561   @xref{Display Custom}, for more information about line truncation,
562 and other variables that affect how text is displayed.
564 @node Position Info
565 @section Cursor Position Information
567   Here are commands to get information about the size and position of
568 parts of the buffer, and to count lines.
570 @table @kbd
571 @item M-x what-page
572 Display the page number of point, and the line number within the page.
573 @item M-x what-line
574 Display the line number of point in the buffer.
575 @item M-x line-number-mode
576 @itemx M-x column-number-mode
577 Toggle automatic display of current line number or column number.
578 @xref{Optional Mode Line}.
579 @item M-=
580 Display the number of lines in the current region (@code{count-lines-region}).
581 @xref{Mark}, for information about the region.
582 @item C-x =
583 Display the character code of character after point, character position of
584 point, and column of point (@code{what-cursor-position}).
585 @item M-x hl-line-mode
586 Enable or disable highlighting of the current line.  @xref{Cursor
587 Display}.
588 @item M-x size-indication-mode
589 Toggle automatic display of the size of the buffer.
590 @xref{Optional Mode Line}.
591 @end table
593 @findex what-page
594 @findex what-line
595 @cindex line number commands
596 @cindex location of point
597 @cindex cursor location
598 @cindex point location
599   @kbd{M-x what-line} computes the current line number and displays it
600 in the echo area.  You can also see the current line number in the
601 mode line; see @ref{Mode Line}.  If you narrow the buffer, then the
602 line number in the mode line is relative to the accessible portion
603 (@pxref{Narrowing}).  By contrast, @code{what-line} shows both the
604 line number relative to the narrowed region and the line number
605 relative to the whole buffer.
607   @kbd{M-x what-page} counts pages from the beginning of the file, and
608 counts lines within the page, showing both numbers in the echo area.
609 @xref{Pages}.
611 @kindex M-=
612 @findex count-lines-region
613   While on this subject, we might as well mention @kbd{M-=} (@code{count-lines-region}),
614 which displays the number of lines in the region (@pxref{Mark}).
615 @xref{Pages}, for the command @kbd{C-x l} which counts the lines in the
616 current page.
618 @kindex C-x =
619 @findex what-cursor-position
620   The command @kbd{C-x =} (@code{what-cursor-position}) shows what
621 column the cursor is in, and other miscellaneous information about
622 point and the character after it.  It displays a line in the echo area
623 that looks like this:
625 @smallexample
626 Char: c (0143, 99, 0x63)  point=21044 of 26883(78%)  column 53
627 @end smallexample
629 @noindent
630 (In fact, this is the output produced when point is before the
631 @samp{column} in the example.)
633   The four values after @samp{Char:} describe the character that follows
634 point, first by showing it and then by giving its character code in
635 octal, decimal and hex.  For a non-@acronym{ASCII} multibyte character, these are
636 followed by @samp{ext} and the character's representation, in hex, in
637 the buffer's coding system, if that coding system encodes the character
638 safely and with a single byte (@pxref{Coding Systems}).  If the
639 character's encoding is longer than one byte, Emacs shows @samp{ext ...}.
641   @samp{point=} is followed by the position of point expressed as a character
642 count.  The front of the buffer counts as position 1, one character later
643 as 2, and so on.  The next, larger, number is the total number of characters
644 in the buffer.  Afterward in parentheses comes the position expressed as a
645 percentage of the total size.
647   @samp{column} is followed by the horizontal position of point, in
648 columns from the left edge of the window.
650   If the buffer has been narrowed, making some of the text at the
651 beginning and the end temporarily inaccessible, @kbd{C-x =} displays
652 additional text describing the currently accessible range.  For example, it
653 might display this:
655 @smallexample
656 Char: C (0103, 67, 0x43)  point=252 of 889(28%) <231 - 599>  column 0
657 @end smallexample
659 @noindent
660 where the two extra numbers give the smallest and largest character
661 position that point is allowed to assume.  The characters between those
662 two positions are the accessible ones.  @xref{Narrowing}.
664   If point is at the end of the buffer (or the end of the accessible
665 part), the @w{@kbd{C-x =}} output does not describe a character after
666 point.  The output might look like this:
668 @smallexample
669 point=26957 of 26956(100%)  column 0
670 @end smallexample
672 @cindex character set of character at point
673 @cindex font of character at point
674 @cindex text properties at point
675   @w{@kbd{C-u C-x =}} displays the following additional information about a
676 character.
678 @itemize @bullet
679 @item
680 The character set name, and the codes that identify the character
681 within that character set; @acronym{ASCII} characters are identified
682 as belonging to the @code{ascii} character set.
684 @item
685 The character's syntax and categories.
687 @item
688 The character's encodings, both internally in the buffer, and externally
689 if you were to save the file.
691 @item
692 What to type to input the character in the current input method
693 (if it supports the character).
695 @item
696 If you are running Emacs on a window system, the font name and glyph
697 code for the character.  If you are running Emacs on a terminal, the
698 code(s) sent to the terminal.
700 @item
701 The character's text properties (@pxref{Text Properties,,,
702 elisp, the Emacs Lisp Reference Manual}), and any overlays containing it
703 (@pxref{Overlays,,, elisp, the same manual}).
704 @end itemize
706   Here's an example showing the Latin-1 character A with grave accent,
707 in a buffer whose coding system is @code{iso-latin-1}, whose
708 terminal coding system is @code{iso-latin-1} (so the terminal actually
709 displays the character as @samp{@`A}), and which has font-lock-mode
710 (@pxref{Font Lock}) enabled:
712 @smallexample
713   character: @`A (04300, 2240, 0x8c0, U+00C0)
714     charset: latin-iso8859-1
715              (Right-Hand Part of Latin Alphabet 1@dots{}
716  code point: 64
717      syntax: w  which means: word
718    category: l:Latin
719    to input: type "`A"
720 buffer code: 0x81 0xC0
721   file code: ESC 2C 41 40 (encoded by coding system iso-2022-7bit)
722     display: terminal code 0xC0
724 There are text properties here:
725   fontified            t
726 @end smallexample
728 @node Arguments
729 @section Numeric Arguments
730 @cindex numeric arguments
731 @cindex prefix arguments
732 @cindex arguments to commands
734   In mathematics and computer usage, the word @dfn{argument} means
735 ``data provided to a function or operation.''  You can give any Emacs
736 command a @dfn{numeric argument} (also called a @dfn{prefix argument}).
737 Some commands interpret the argument as a repetition count.  For
738 example, @kbd{C-f} with an argument of ten moves forward ten characters
739 instead of one.  With these commands, no argument is equivalent to an
740 argument of one.  Negative arguments tell most such commands to move or
741 act in the opposite direction.
743 @kindex M-1
744 @kindex M-@t{-}
745 @findex digit-argument
746 @findex negative-argument
747   If your terminal keyboard has a @key{META} key (labeled @key{ALT} on
748 PC keyboards), the easiest way to specify a numeric argument is to
749 type digits and/or a minus sign while holding down the @key{META} key.
750 For example,
752 @example
753 M-5 C-n
754 @end example
756 @noindent
757 would move down five lines.  The characters @kbd{Meta-1}, @kbd{Meta-2},
758 and so on, as well as @kbd{Meta--}, do this because they are keys bound
759 to commands (@code{digit-argument} and @code{negative-argument}) that
760 are defined to contribute to an argument for the next command.
761 @kbd{Meta--} without digits normally means @minus{}1.  Digits and
762 @kbd{-} modified with Control, or Control and Meta, also specify numeric
763 arguments.
765 @kindex C-u
766 @findex universal-argument
767   Another way of specifying an argument is to use the @kbd{C-u}
768 (@code{universal-argument}) command followed by the digits of the
769 argument.  With @kbd{C-u}, you can type the argument digits without
770 holding down modifier keys; @kbd{C-u} works on all terminals.  To type a
771 negative argument, type a minus sign after @kbd{C-u}.  Just a minus sign
772 without digits normally means @minus{}1.
774   @kbd{C-u} followed by a character which is neither a digit nor a minus
775 sign has the special meaning of ``multiply by four.''  It multiplies the
776 argument for the next command by four.  @kbd{C-u} twice multiplies it by
777 sixteen.  Thus, @kbd{C-u C-u C-f} moves forward sixteen characters.  This
778 is a good way to move forward ``fast,'' since it moves about 1/5 of a line
779 in the usual size screen.  Other useful combinations are @kbd{C-u C-n},
780 @kbd{C-u C-u C-n} (move down a good fraction of a screen), @kbd{C-u C-u
781 C-o} (make ``a lot'' of blank lines), and @kbd{C-u C-k} (kill four
782 lines).@refill
784   Some commands care only about whether there is an argument, and not about
785 its value.  For example, the command @kbd{M-q} (@code{fill-paragraph}) with
786 no argument fills text; with an argument, it justifies the text as well.
787 (@xref{Filling}, for more information on @kbd{M-q}.)  Plain @kbd{C-u} is a
788 handy way of providing an argument for such commands.
790   Some commands use the value of the argument as a repeat count, but do
791 something peculiar when there is no argument.  For example, the command
792 @kbd{C-k} (@code{kill-line}) with argument @var{n} kills @var{n} lines,
793 including their terminating newlines.  But @kbd{C-k} with no argument is
794 special: it kills the text up to the next newline, or, if point is right at
795 the end of the line, it kills the newline itself.  Thus, two @kbd{C-k}
796 commands with no arguments can kill a nonblank line, just like @kbd{C-k}
797 with an argument of one.  (@xref{Killing}, for more information on
798 @kbd{C-k}.)@refill
800   A few commands treat a plain @kbd{C-u} differently from an ordinary
801 argument.  A few others may treat an argument of just a minus sign
802 differently from an argument of @minus{}1.  These unusual cases are
803 described when they come up; they are always for reasons of
804 convenience of use of the individual command, and they are documented
805 in the command's documentation string.
807   You can use a numeric argument to insert multiple copies of a
808 character.  This is straightforward unless the character is a digit; for
809 example, @kbd{C-u 6 4 a} inserts 64 copies of the character @samp{a}.
810 But this does not work for inserting digits; @kbd{C-u 6 4 1} specifies
811 an argument of 641, rather than inserting anything.  To separate the
812 digit to insert from the argument, type another @kbd{C-u}; for example,
813 @kbd{C-u 6 4 C-u 1} does insert 64 copies of the character @samp{1}.
815   We use the term ``prefix argument'' as well as ``numeric argument'' to
816 emphasize that you type the argument before the command, and to
817 distinguish these arguments from minibuffer arguments that come after
818 the command.
820 @node Repeating
821 @section Repeating a Command
822 @cindex repeating a command
824   Many simple commands, such as those invoked with a single key or
825 with @kbd{M-x @var{command-name} @key{RET}}, can be repeated by
826 invoking them with a numeric argument that serves as a repeat count
827 (@pxref{Arguments}).  However, if the command you want to repeat
828 prompts for some input, or uses a numeric argument in another way,
829 repetition using a numeric argument might be problematical.
831 @kindex C-x z
832 @findex repeat
833   The command @kbd{C-x z} (@code{repeat}) provides another way to repeat
834 an Emacs command many times.  This command repeats the previous Emacs
835 command, whatever that was.  Repeating a command uses the same arguments
836 that were used before; it does not read new arguments each time.
838   To repeat the command more than once, type additional @kbd{z}'s: each
839 @kbd{z} repeats the command one more time.  Repetition ends when you
840 type a character other than @kbd{z}, or press a mouse button.
842   For example, suppose you type @kbd{C-u 2 0 C-d} to delete 20
843 characters.  You can repeat that command (including its argument) three
844 additional times, to delete a total of 80 characters, by typing @kbd{C-x
845 z z z}.  The first @kbd{C-x z} repeats the command once, and each
846 subsequent @kbd{z} repeats it once again.
848 @ignore
849    arch-tag: cda8952a-c439-41c1-aecf-4bc0d6482956
850 @end ignore