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