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