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