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