Commit | Line | Data |
---|---|---|
6bf7aab6 | 1 | @c This is part of the Emacs manual. |
b65d8176 | 2 | @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001, |
4e6835db | 3 | @c 2002, 2003, 2004, 2005, 2006, 2007 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 | |
411fe8f3 RS |
10 | Here we explain the basics of how to enter text, make corrections, |
11 | and save the text in a file. If this material is new to you, we | |
12 | suggest you first run the Emacs learn-by-doing tutorial, by typing | |
13 | @kbd{Control-h t} inside Emacs. (@code{help-with-tutorial}). | |
6bf7aab6 | 14 | |
411fe8f3 | 15 | To clear and redisplay the screen, type @kbd{C-l} (@code{recenter}). |
6bf7aab6 DL |
16 | |
17 | @menu | |
18 | ||
19 | * Inserting Text:: Inserting text by simply typing it. | |
411fe8f3 | 20 | * Moving Point:: Moving the cursor to the place where you want to |
6bf7aab6 DL |
21 | change something. |
22 | * Erasing:: Deleting and killing text. | |
dc9bfb46 | 23 | * Basic Undo:: Undoing recent changes in the text. |
6bf7aab6 DL |
24 | * Files: Basic Files. Visiting, creating, and saving files. |
25 | * Help: Basic Help. Asking what a character does. | |
411fe8f3 RS |
26 | * Blank Lines:: Making and deleting blank lines. |
27 | * Continuation Lines:: How Emacs displays lines too wide for the screen. | |
6bf7aab6 | 28 | * Position Info:: What page, line, row, or column is point on? |
411fe8f3 RS |
29 | * Arguments:: Numeric arguments for repeating a command N times. |
30 | * Repeating:: Repeating the previous command quickly. | |
6bf7aab6 DL |
31 | @end menu |
32 | ||
33 | @node Inserting Text | |
34 | @section Inserting Text | |
35 | ||
36 | @cindex insertion | |
37 | @cindex graphic characters | |
411fe8f3 RS |
38 | Typing printing characters inserts them into the text you are |
39 | editing. It inserts them into the buffer at the cursor; more | |
40 | precisely, it inserts them at @dfn{point}, but the cursor normally | |
41 | shows where point is. @xref{Point}. | |
42 | ||
43 | Insertion moves the cursor forward, and the following text moves | |
44 | forward with the cursor. If the text in the buffer is @samp{FOOBAR}, | |
45 | with the cursor before the @samp{B}, and you type @kbd{XX}, you get | |
46 | @samp{FOOXXBAR}, with the cursor still before the @samp{B}. | |
6bf7aab6 | 47 | |
06a97e7d RS |
48 | To @dfn{delete} text you have just inserted, use the large key |
49 | labeled @key{DEL}, @key{BACKSPACE} or @key{DELETE} which is a short | |
411fe8f3 RS |
50 | distance above the @key{RET} or @key{ENTER} key. Regardless of the |
51 | label on that key, Emacs thinks of it as @key{DEL}, and that's what we | |
52 | call it in this manual. @key{DEL} is the key you normally use outside | |
53 | Emacs to erase the last character that you typed. | |
6bf7aab6 | 54 | |
06a97e7d RS |
55 | The @key{DEL} key deletes the character @emph{before} the cursor. |
56 | As a consequence, the cursor and all the characters after it move | |
57 | backwards. If you type a printing character and then type @key{DEL}, | |
58 | they cancel out. | |
59 | ||
411fe8f3 RS |
60 | On most computers, Emacs sets up @key{DEL} automatically. In some |
61 | cases, especially with text-only terminals, Emacs may guess wrong. If | |
62 | the key that ought to erase the last character doesn't do it in Emacs, | |
63 | see @ref{DEL Does Not Delete}. | |
9ab48fa6 | 64 | |
411fe8f3 RS |
65 | Most PC keyboards have both a @key{BACKSPACE} key a little ways |
66 | above @key{RET} or @key{ENTER}, and a @key{DELETE} key elsewhere. On | |
67 | these keyboards, Emacs tries to set up @key{BACKSPACE} as @key{DEL}. | |
68 | The @key{DELETE} key deletes ``forwards'' like @kbd{C-d} (see below), | |
69 | which means it deletes the character underneath the cursor (after | |
70 | point). | |
06a97e7d | 71 | |
6bf7aab6 DL |
72 | @kindex RET |
73 | @cindex newline | |
411fe8f3 RS |
74 | To end a line and start typing a new one, type @key{RET}. (This |
75 | key may be labeled @key{RETURN} or @key{ENTER}, but in Emacs we call | |
76 | it @key{RET}.) This inserts a newline character in the buffer. If | |
77 | point is at the end of the line, this creates a new blank line after | |
78 | it. If point is in the middle of a line, the effect is to split that | |
79 | line. Typing @key{DEL} when the cursor is at the beginning of a line | |
80 | deletes the preceding newline character, thus joining the line with | |
81 | the one before it. | |
82 | ||
83 | Emacs can split lines automatically when they become too long, if | |
84 | you turn on a special minor mode called @dfn{Auto Fill} mode. | |
85 | @xref{Filling}, for Auto Fill mode and other methods of @dfn{filling} | |
86 | text. | |
87 | ||
88 | If you prefer printing characters to replace (overwrite) existing | |
89 | text, rather than shove it to the right, you should enable Overwrite | |
90 | mode, a minor mode. @xref{Minor Modes}. | |
6bf7aab6 DL |
91 | |
92 | @cindex quoting | |
93 | @kindex C-q | |
94 | @findex quoted-insert | |
411fe8f3 RS |
95 | Only printing characters and @key{SPC} insert themselves in Emacs. |
96 | Other characters act as editing commands and do not insert themselves. | |
97 | These include control characters, and characters with codes above 200 | |
98 | octal. If you need to insert one of these characters in the buffer, | |
99 | you must @dfn{quote} it by typing the character @kbd{Control-q} | |
100 | (@code{quoted-insert}) first. (This character's name is normally | |
101 | written @kbd{C-q} for short.) There are two ways to use | |
102 | @kbd{C-q}: | |
6bf7aab6 DL |
103 | |
104 | @itemize @bullet | |
105 | @item | |
106 | @kbd{C-q} followed by any non-graphic character (even @kbd{C-g}) | |
107 | inserts that character. | |
108 | ||
109 | @item | |
110 | @kbd{C-q} followed by a sequence of octal digits inserts the character | |
111 | with the specified octal character code. You can use any number of | |
9acb8eec RS |
112 | octal digits; any non-digit terminates the sequence. If the |
113 | terminating character is @key{RET}, it serves only to terminate the | |
114 | sequence. Any other non-digit terminates the sequence and then acts | |
115 | as normal input---thus, @kbd{C-q 1 0 1 B} inserts @samp{AB}. | |
116 | ||
117 | The use of octal sequences is disabled in ordinary non-binary | |
118 | Overwrite mode, to give you a convenient way to insert a digit instead | |
119 | of overwriting with it. | |
6bf7aab6 DL |
120 | @end itemize |
121 | ||
b5d1e464 | 122 | @cindex 8-bit character codes |
6bf7aab6 | 123 | @noindent |
d3e94981 | 124 | When multibyte characters are enabled, if you specify a code in the |
093b0ab5 RS |
125 | range 0200 through 0377 octal, @kbd{C-q} assumes that you intend to |
126 | use some ISO 8859-@var{n} character set, and converts the specified | |
127 | code to the corresponding Emacs character code. @xref{Enabling | |
128 | Multibyte}. You select @emph{which} of the ISO 8859 character sets to | |
129 | use through your choice of language environment (@pxref{Language | |
130 | Environments}). | |
6bf7aab6 DL |
131 | |
132 | @vindex read-quoted-char-radix | |
133 | To use decimal or hexadecimal instead of octal, set the variable | |
134 | @code{read-quoted-char-radix} to 10 or 16. If the radix is greater than | |
135 | 10, some letters starting with @kbd{a} serve as part of a character | |
136 | code, just like digits. | |
137 | ||
411fe8f3 RS |
138 | A numeric argument tells @kbd{C-q} how many copies of the quoted |
139 | character to insert (@pxref{Arguments}). | |
6bf7aab6 DL |
140 | |
141 | @findex newline | |
142 | @findex self-insert | |
143 | Customization information: @key{DEL} in most modes runs the command | |
411fe8f3 RS |
144 | @code{delete-backward-char}; @key{RET} runs the command |
145 | @code{newline}, and self-inserting printing characters run the command | |
146 | @code{self-insert}, which inserts whatever character you typed. Some | |
147 | major modes rebind @key{DEL} to other commands. | |
6bf7aab6 DL |
148 | |
149 | @node Moving Point | |
150 | @section Changing the Location of Point | |
151 | ||
152 | @cindex arrow keys | |
6bf7aab6 DL |
153 | @cindex moving point |
154 | @cindex movement | |
155 | @cindex cursor motion | |
156 | @cindex moving the cursor | |
157 | To do more than insert characters, you have to know how to move point | |
158 | (@pxref{Point}). The simplest way to do this is with arrow keys, or by | |
159 | clicking the left mouse button where you want to move to. | |
160 | ||
161 | There are also control and meta characters for cursor motion. Some | |
b96ade76 RS |
162 | are equivalent to the arrow keys (it is faster to use these control |
163 | keys than move your hand over to the arrow keys). Others do more | |
164 | sophisticated things. | |
6bf7aab6 DL |
165 | |
166 | @kindex C-a | |
167 | @kindex C-e | |
168 | @kindex C-f | |
169 | @kindex C-b | |
170 | @kindex C-n | |
171 | @kindex C-p | |
172 | @kindex M-> | |
173 | @kindex M-< | |
174 | @kindex M-r | |
06a97e7d RS |
175 | @kindex LEFT |
176 | @kindex RIGHT | |
177 | @kindex UP | |
178 | @kindex DOWN | |
c7bda15b | 179 | @findex move-beginning-of-line |
aa3dd3b5 | 180 | @findex move-end-of-line |
6bf7aab6 DL |
181 | @findex forward-char |
182 | @findex backward-char | |
183 | @findex next-line | |
184 | @findex previous-line | |
185 | @findex beginning-of-buffer | |
186 | @findex end-of-buffer | |
187 | @findex goto-char | |
188 | @findex goto-line | |
189 | @findex move-to-window-line | |
190 | @table @kbd | |
191 | @item C-a | |
c7bda15b | 192 | Move to the beginning of the line (@code{move-beginning-of-line}). |
6bf7aab6 | 193 | @item C-e |
aa3dd3b5 | 194 | Move to the end of the line (@code{move-end-of-line}). |
6bf7aab6 | 195 | @item C-f |
06a97e7d RS |
196 | Move forward one character (@code{forward-char}). The right-arrow key |
197 | does the same thing. | |
6bf7aab6 | 198 | @item C-b |
06a97e7d RS |
199 | Move backward one character (@code{backward-char}). The left-arrow |
200 | key has the same effect. | |
6bf7aab6 DL |
201 | @item M-f |
202 | Move forward one word (@code{forward-word}). | |
203 | @item M-b | |
204 | Move backward one word (@code{backward-word}). | |
205 | @item C-n | |
411fe8f3 | 206 | Move down one line vertically (@code{next-line}). This command |
6bf7aab6 | 207 | attempts to keep the horizontal position unchanged, so if you start in |
411fe8f3 | 208 | the middle of one line, you move to the middle of the next. The |
06a97e7d | 209 | down-arrow key does the same thing. |
6bf7aab6 | 210 | @item C-p |
06a97e7d | 211 | Move up one line, vertically (@code{previous-line}). The up-arrow key |
411fe8f3 RS |
212 | has the same effect. This command preserves position within the line, |
213 | like @kbd{C-n}. | |
6bf7aab6 DL |
214 | @item M-r |
215 | Move point to left margin, vertically centered in the window | |
216 | (@code{move-to-window-line}). Text does not move on the screen. | |
411fe8f3 RS |
217 | A numeric argument says which screen line to place point on, counting |
218 | downward from the top of the window (zero means the top line). A | |
219 | negative argument counts lines up from the bottom (@minus{}1 means the | |
220 | bottom line). | |
6bf7aab6 DL |
221 | @item M-< |
222 | Move to the top of the buffer (@code{beginning-of-buffer}). With | |
223 | numeric argument @var{n}, move to @var{n}/10 of the way from the top. | |
224 | @xref{Arguments}, for more information on numeric arguments.@refill | |
225 | @item M-> | |
226 | Move to the end of the buffer (@code{end-of-buffer}). | |
06a97e7d | 227 | @item C-v |
1b53c26e RS |
228 | @itemx @key{PAGEDOWN} |
229 | @itemx @key{PRIOR} | |
230 | Scroll the display one screen forward, and move point if necessary to | |
231 | put it on the screen (@code{scroll-up}). This doesn't always move | |
232 | point, but it is commonly used to do so. If your keyboard has a | |
233 | @key{PAGEDOWN} or @key{PRIOR} key, it does the same thing. | |
06a97e7d | 234 | |
411fe8f3 | 235 | Scrolling commands are described further in @ref{Scrolling}. |
06a97e7d | 236 | @item M-v |
1b53c26e RS |
237 | @itemx @key{PAGEUP} |
238 | @itemx @key{NEXT} | |
06a97e7d RS |
239 | Scroll one screen backward, and move point if necessary to put it on |
240 | the screen (@code{scroll-down}). This doesn't always move point, but | |
1b53c26e RS |
241 | it is commonly used to do so. If your keyboard has a @key{PAGEUP} or |
242 | @key{NEXT} key, it does the same thing. | |
6bf7aab6 DL |
243 | @item M-x goto-char |
244 | Read a number @var{n} and move point to buffer position @var{n}. | |
245 | Position 1 is the beginning of the buffer. | |
33e54c87 | 246 | @item M-g M-g |
706f4350 | 247 | @itemx M-g g |
33e54c87 | 248 | @itemx M-x goto-line |
48c13f3e LT |
249 | Read a number @var{n} and move point to the beginning of line number |
250 | @var{n}. Line 1 is the beginning of the buffer. If point is on or | |
411fe8f3 RS |
251 | just after a number in the buffer, and you type @key{RET} with the |
252 | minibuffer empty, that number is used for @var{n}. | |
6bf7aab6 DL |
253 | @item C-x C-n |
254 | @findex set-goal-column | |
255 | @kindex C-x C-n | |
411fe8f3 | 256 | Use the current column of point as the @dfn{semipermanent goal column} |
d3b87ec4 RS |
257 | for @kbd{C-n} and @kbd{C-p} (@code{set-goal-column}). When a |
258 | semipermanent goal column is in effect, those commands always try to | |
259 | move to this column, or as close as possible to it, after moving | |
260 | vertically. The goal column remains in effect until canceled. | |
6bf7aab6 | 261 | @item C-u C-x C-n |
411fe8f3 RS |
262 | Cancel the goal column. Henceforth, @kbd{C-n} and @kbd{C-p} try to |
263 | preserve the horizontal position, as usual. | |
6bf7aab6 DL |
264 | @end table |
265 | ||
266 | @vindex track-eol | |
267 | If you set the variable @code{track-eol} to a non-@code{nil} value, | |
015a26d7 | 268 | then @kbd{C-n} and @kbd{C-p}, when starting at the end of the line, move |
6bf7aab6 DL |
269 | to the end of another line. Normally, @code{track-eol} is @code{nil}. |
270 | @xref{Variables}, for how to set variables such as @code{track-eol}. | |
271 | ||
272 | @vindex next-line-add-newlines | |
c7bda15b | 273 | @kbd{C-n} normally stops at the end of the buffer when you use it on |
411fe8f3 | 274 | the last line of the buffer. However, if you set the variable |
1b53c26e RS |
275 | @code{next-line-add-newlines} to a non-@code{nil} value, @kbd{C-n} on |
276 | the last line of a buffer creates an additional line at the end and | |
411fe8f3 | 277 | moves down into it. |
6bf7aab6 | 278 | |
177c0ea7 | 279 | @node Erasing |
6bf7aab6 DL |
280 | @section Erasing Text |
281 | ||
282 | @table @kbd | |
283 | @item @key{DEL} | |
284 | Delete the character before point (@code{delete-backward-char}). | |
285 | @item C-d | |
286 | Delete the character after point (@code{delete-char}). | |
06a97e7d RS |
287 | @item @key{DELETE} |
288 | @itemx @key{BACKSPACE} | |
289 | One of these keys, whichever is the large key above the @key{RET} or | |
b96ade76 RS |
290 | @key{ENTER} key, deletes the character before point---it is @key{DEL}. |
291 | If @key{BACKSPACE} is @key{DEL}, and your keyboard also has @key{DELETE}, | |
06a97e7d | 292 | then @key{DELETE} deletes forwards, like @kbd{C-d}. |
6bf7aab6 DL |
293 | @item C-k |
294 | Kill to the end of the line (@code{kill-line}). | |
295 | @item M-d | |
296 | Kill forward to the end of the next word (@code{kill-word}). | |
297 | @item M-@key{DEL} | |
298 | Kill back to the beginning of the previous word | |
299 | (@code{backward-kill-word}). | |
300 | @end table | |
301 | ||
302 | @cindex killing characters and lines | |
303 | @cindex deleting characters and lines | |
304 | @cindex erasing characters and lines | |
305 | You already know about the @key{DEL} key which deletes the character | |
306 | before point (that is, before the cursor). Another key, @kbd{Control-d} | |
307 | (@kbd{C-d} for short), deletes the character after point (that is, the | |
308 | character that the cursor is on). This shifts the rest of the text on | |
309 | the line to the left. If you type @kbd{C-d} at the end of a line, it | |
411fe8f3 | 310 | joins that line with the following line. |
6bf7aab6 | 311 | |
411fe8f3 RS |
312 | To erase a larger amount of text, use the @kbd{C-k} key, which |
313 | erases (kills) a line at a time. If you type @kbd{C-k} at the | |
314 | beginning or middle of a line, it kills all the text up to the end of | |
315 | the line. If you type @kbd{C-k} at the end of a line, it joins that | |
316 | line with the following line. | |
6bf7aab6 DL |
317 | |
318 | @xref{Killing}, for more flexible ways of killing text. | |
319 | ||
dc9bfb46 | 320 | @node Basic Undo |
6bf7aab6 | 321 | @section Undoing Changes |
6bf7aab6 | 322 | |
dc9bfb46 | 323 | Emacs records a list of changes made in the buffer text, so you can |
411fe8f3 | 324 | you can undo recent changes, as far as the records go. |
dc9bfb46 RS |
325 | Usually each editing command makes a separate entry in the undo |
326 | records, but sometimes an entry covers just part of a command, and | |
327 | very simple commands may be grouped. | |
6bf7aab6 DL |
328 | |
329 | @table @kbd | |
330 | @item C-x u | |
dc9bfb46 RS |
331 | Undo one entry of the undo records---usually, one command worth |
332 | (@code{undo}). | |
6bf7aab6 | 333 | @item C-_ |
1b53c26e | 334 | @itemx C-/ |
6bf7aab6 | 335 | The same. |
6bf7aab6 DL |
336 | @end table |
337 | ||
1b53c26e | 338 | The command @kbd{C-x u} (or @kbd{C-_} or @kbd{C-/}) is how you undo. |
411fe8f3 RS |
339 | Normally this command undoes the last change, and moves point back to |
340 | where it was before the change. | |
6bf7aab6 | 341 | |
411fe8f3 RS |
342 | If you repeat @kbd{C-x u} (or its aliases), each repetition undoes |
343 | another, earlier change, back to the limit of the undo information | |
dc9bfb46 RS |
344 | available. If all recorded changes have already been undone, the undo |
345 | command displays an error message and does nothing. | |
6bf7aab6 | 346 | |
b96ade76 RS |
347 | The undo command applies only to changes in the buffer; you can't |
348 | use it to undo mere cursor motion. However, some cursor motion | |
349 | commands set the mark, so if you use these commands from time to time, | |
350 | you can move back to the neighborhoods you have moved through by | |
351 | popping the mark ring (@pxref{Mark Ring}). | |
6bf7aab6 | 352 | |
6bf7aab6 DL |
353 | @node Basic Files |
354 | @section Files | |
355 | ||
411fe8f3 RS |
356 | Text that you insert in an Emacs buffer lasts only as long as the |
357 | Emacs session. To keep any text permanently you must put it in a | |
6bf7aab6 | 358 | @dfn{file}. Files are named units of text which are stored by the |
411fe8f3 RS |
359 | operating system for you to retrieve later by name. To use the |
360 | contents of a file in any way, you must specify the file name. That | |
361 | includes editing the file with Emacs. | |
6bf7aab6 | 362 | |
411fe8f3 RS |
363 | Suppose there is a file named @file{test.emacs} in your home |
364 | directory. To begin editing this file in Emacs, type | |
6bf7aab6 DL |
365 | |
366 | @example | |
b96ade76 | 367 | C-x C-f test.emacs @key{RET} |
6bf7aab6 DL |
368 | @end example |
369 | ||
370 | @noindent | |
371 | Here the file name is given as an @dfn{argument} to the command @kbd{C-x | |
372 | C-f} (@code{find-file}). That command uses the @dfn{minibuffer} to | |
373 | read the argument, and you type @key{RET} to terminate the argument | |
411fe8f3 | 374 | (@pxref{Minibuffer}). |
6bf7aab6 | 375 | |
411fe8f3 RS |
376 | Emacs obeys this command by @dfn{visiting} the file: it creates a |
377 | buffer, it copies the contents of the file into the buffer, and then | |
378 | displays the buffer for editing. If you alter the text, you can | |
379 | @dfn{save} the new text in the file by typing @kbd{C-x C-s} | |
380 | (@code{save-buffer}). This copies the altered buffer contents back | |
381 | into the file @file{test.emacs}, making them permanent. Until you | |
382 | save, the changed text exists only inside Emacs, and the file | |
383 | @file{test.emacs} is unaltered. | |
6bf7aab6 | 384 | |
411fe8f3 RS |
385 | To create a file, just visit it with @kbd{C-x C-f} as if it already |
386 | existed. This creates an empty buffer, in which you can insert the | |
387 | text you want to put in the file. Emacs actually creates the file the | |
388 | first time you save this buffer with @kbd{C-x C-s}. | |
6bf7aab6 | 389 | |
411fe8f3 | 390 | To learn more about using files in Emacs, see @ref{Files}. |
6bf7aab6 DL |
391 | |
392 | @node Basic Help | |
393 | @section Help | |
394 | ||
395 | @cindex getting help with keys | |
396 | If you forget what a key does, you can find out with the Help | |
397 | character, which is @kbd{C-h} (or @key{F1}, which is an alias for | |
411fe8f3 RS |
398 | @kbd{C-h}). Type @kbd{C-h k} followed by the key of interest; for |
399 | example, @kbd{C-h k C-n} tells you what @kbd{C-n} does. @kbd{C-h} is | |
400 | a prefix key; @kbd{C-h k} is just one of its subcommands (the command | |
401 | @code{describe-key}). The other subcommands of @kbd{C-h} provide | |
402 | different kinds of help. Type @kbd{C-h} twice to get a description of | |
403 | all the help facilities. @xref{Help}. | |
6bf7aab6 DL |
404 | |
405 | @node Blank Lines | |
406 | @section Blank Lines | |
407 | ||
408 | @cindex inserting blank lines | |
409 | @cindex deleting blank lines | |
411fe8f3 | 410 | Here are special commands and techniques for inserting and deleting |
6bf7aab6 DL |
411 | blank lines. |
412 | ||
6bf7aab6 DL |
413 | @table @kbd |
414 | @item C-o | |
415 | Insert one or more blank lines after the cursor (@code{open-line}). | |
416 | @item C-x C-o | |
417 | Delete all but one of many consecutive blank lines | |
418 | (@code{delete-blank-lines}). | |
419 | @end table | |
420 | ||
421 | @kindex C-o | |
422 | @kindex C-x C-o | |
423 | @cindex blank lines | |
424 | @findex open-line | |
425 | @findex delete-blank-lines | |
411fe8f3 RS |
426 | To insert a new line of text before an existing line, |
427 | type the new line of text, followed by @key{RET}. | |
6bf7aab6 DL |
428 | However, it may be easier to see what you are doing if you first make a |
429 | blank line and then insert the desired text into it. This is easy to do | |
430 | using the key @kbd{C-o} (@code{open-line}), which inserts a newline | |
431 | after point but leaves point in front of the newline. After @kbd{C-o}, | |
432 | type the text for the new line. @kbd{C-o F O O} has the same effect as | |
433 | @w{@kbd{F O O @key{RET}}}, except for the final location of point. | |
434 | ||
435 | You can make several blank lines by typing @kbd{C-o} several times, or | |
411fe8f3 | 436 | by giving it a numeric argument specifying how many blank lines to make. |
c7bda15b | 437 | @xref{Arguments}, for how. If you have a fill prefix, the @kbd{C-o} |
411fe8f3 | 438 | command inserts the fill prefix on the new line, if typed at the |
6bf7aab6 DL |
439 | beginning of a line. @xref{Fill Prefix}. |
440 | ||
441 | The easy way to get rid of extra blank lines is with the command | |
442 | @kbd{C-x C-o} (@code{delete-blank-lines}). @kbd{C-x C-o} in a run of | |
443 | several blank lines deletes all but one of them. @kbd{C-x C-o} on a | |
411fe8f3 RS |
444 | lone blank line deletes that one. When point is on a nonblank line, |
445 | @kbd{C-x C-o} deletes all following blank lines (if any). | |
6bf7aab6 DL |
446 | |
447 | @node Continuation Lines | |
448 | @section Continuation Lines | |
449 | ||
450 | @cindex continuation line | |
451 | @cindex wrapping | |
452 | @cindex line wrapping | |
e56823d9 | 453 | @cindex fringes, and continuation lines |
411fe8f3 RS |
454 | When a text line is too long to fit in one screen line, Emacs |
455 | displays it on two or more screen lines. This is called | |
456 | @dfn{continuation} or @dfn{line wrapping}. On graphical displays, | |
457 | Emacs indicates line wrapping with small bent arrows in the left and | |
458 | right window fringes. On text-only terminals, Emacs displays a | |
459 | @samp{\} character at the right margin of a screen line if it is not | |
460 | the last in its text line. This @samp{\} character says that the | |
461 | following screen line is not really a new text line. | |
462 | ||
463 | When line wrapping occurs just before a character that is wider than one | |
093b0ab5 RS |
464 | column, some columns at the end of the previous screen line may be |
465 | ``empty.'' In this case, Emacs displays additional @samp{\} | |
411fe8f3 | 466 | characters in the ``empty'' columns before the @samp{\} |
093b0ab5 | 467 | character that indicates continuation. |
6bf7aab6 | 468 | |
411fe8f3 RS |
469 | Continued lines can be difficult to read, since lines can break in |
470 | the middle of a word. If you prefer, you can make Emacs insert a | |
a102b252 | 471 | newline automatically when a line gets too long, by using Auto Fill |
411fe8f3 RS |
472 | mode. Or enable Long Lines mode, which ensures that wrapping only |
473 | occurs between words. @xref{Filling}. | |
6bf7aab6 | 474 | |
6bf7aab6 | 475 | @cindex truncation |
e56823d9 | 476 | @cindex line truncation, and fringes |
411fe8f3 RS |
477 | Emacs can optionally @dfn{truncate} long lines---this means |
478 | displaying just one screen line worth, and the rest of the long line | |
479 | does not appear at all. @samp{$} in the last column or a small | |
480 | straight arrow in the window's right fringe indicates a truncated | |
481 | line. | |
ab527690 | 482 | |
31ee9e8a | 483 | @xref{Line Truncation}, for more about line truncation, |
411fe8f3 | 484 | and other variables that control how text is displayed. |
6bf7aab6 DL |
485 | |
486 | @node Position Info | |
487 | @section Cursor Position Information | |
488 | ||
489 | Here are commands to get information about the size and position of | |
490 | parts of the buffer, and to count lines. | |
491 | ||
492 | @table @kbd | |
493 | @item M-x what-page | |
411fe8f3 | 494 | Display the page number of point, and the line number within that page. |
6bf7aab6 | 495 | @item M-x what-line |
411fe8f3 | 496 | Display the line number of point in the whole buffer. |
6bf7aab6 | 497 | @item M-x line-number-mode |
67675c0f | 498 | @itemx M-x column-number-mode |
411fe8f3 | 499 | Toggle automatic display of the current line number or column number. |
67675c0f | 500 | @xref{Optional Mode Line}. |
6bf7aab6 | 501 | @item M-= |
093b0ab5 | 502 | Display the number of lines in the current region (@code{count-lines-region}). |
6bf7aab6 DL |
503 | @xref{Mark}, for information about the region. |
504 | @item C-x = | |
093b0ab5 | 505 | Display the character code of character after point, character position of |
6bf7aab6 | 506 | point, and column of point (@code{what-cursor-position}). |
67675c0f | 507 | @item M-x hl-line-mode |
83440f52 EZ |
508 | Enable or disable highlighting of the current line. @xref{Cursor |
509 | Display}. | |
ffa11cf3 LK |
510 | @item M-x size-indication-mode |
511 | Toggle automatic display of the size of the buffer. | |
512 | @xref{Optional Mode Line}. | |
6bf7aab6 DL |
513 | @end table |
514 | ||
515 | @findex what-page | |
516 | @findex what-line | |
517 | @cindex line number commands | |
518 | @cindex location of point | |
519 | @cindex cursor location | |
520 | @cindex point location | |
411fe8f3 | 521 | @kbd{M-x what-line} displays the current line number |
706f4350 | 522 | in the echo area. You can also see the current line number in the |
411fe8f3 | 523 | mode line; see @ref{Mode Line}; but if you narrow the buffer, the |
706f4350 LT |
524 | line number in the mode line is relative to the accessible portion |
525 | (@pxref{Narrowing}). By contrast, @code{what-line} shows both the | |
526 | line number relative to the narrowed region and the line number | |
527 | relative to the whole buffer. | |
6bf7aab6 | 528 | |
9acb8eec | 529 | @kbd{M-x what-page} counts pages from the beginning of the file, and |
1ba2ce68 RS |
530 | counts lines within the page, showing both numbers in the echo area. |
531 | @xref{Pages}. | |
6bf7aab6 DL |
532 | |
533 | @kindex M-= | |
534 | @findex count-lines-region | |
411fe8f3 RS |
535 | Use @kbd{M-=} (@code{count-lines-region}) to displays the number of |
536 | lines in the region (@pxref{Mark}). @xref{Pages}, for the command | |
537 | @kbd{C-x l} which counts the lines in the current page. | |
6bf7aab6 DL |
538 | |
539 | @kindex C-x = | |
540 | @findex what-cursor-position | |
6cf1bebc | 541 | The command @kbd{C-x =} (@code{what-cursor-position}) shows what |
411fe8f3 RS |
542 | cursor's column position, and other information about point and the |
543 | character after it. It displays a line in the echo area that looks | |
544 | like this: | |
6bf7aab6 DL |
545 | |
546 | @smallexample | |
fe7c712e | 547 | Char: c (99, #o143, #x63) point=28062 of 36168 (78%) column=53 |
6bf7aab6 DL |
548 | @end smallexample |
549 | ||
6bf7aab6 DL |
550 | The four values after @samp{Char:} describe the character that follows |
551 | point, first by showing it and then by giving its character code in | |
fe7c712e | 552 | decimal, octal and hex. For a non-@acronym{ASCII} multibyte character, these are |
339ef8ce | 553 | followed by @samp{file} and the character's representation, in hex, in |
6bf7aab6 DL |
554 | the buffer's coding system, if that coding system encodes the character |
555 | safely and with a single byte (@pxref{Coding Systems}). If the | |
339ef8ce KH |
556 | character's encoding is longer than one byte, Emacs shows @samp{file ...}. |
557 | ||
558 | However, if the character displayed is in the range 0200 through | |
170e42a1 KH |
559 | 0377 octal, it may actually stand for an invalid UTF-8 byte read from |
560 | a file. In Emacs, that byte is represented as a sequence of 8-bit | |
561 | characters, but all of them together display as the original invalid | |
562 | byte, in octal code. In this case, @kbd{C-x =} shows @samp{part of | |
563 | display ...} instead of @samp{file}. | |
6bf7aab6 | 564 | |
411fe8f3 RS |
565 | @samp{point=} is followed by the position of point expressed as a |
566 | character count. The start of the buffer is position 1, one character | |
567 | later is position 2, and so on. The next, larger, number is the total | |
568 | number of characters in the buffer. Afterward in parentheses comes | |
569 | the position expressed as a percentage of the total size. | |
6bf7aab6 | 570 | |
fe7c712e | 571 | @samp{column=} is followed by the horizontal position of point, in |
6bf7aab6 DL |
572 | columns from the left edge of the window. |
573 | ||
574 | If the buffer has been narrowed, making some of the text at the | |
1ba2ce68 | 575 | beginning and the end temporarily inaccessible, @kbd{C-x =} displays |
6bf7aab6 DL |
576 | additional text describing the currently accessible range. For example, it |
577 | might display this: | |
578 | ||
579 | @smallexample | |
fe7c712e | 580 | Char: C (67, #o103, #x43) point=252 of 889 (28%) <231-599> column=0 |
6bf7aab6 DL |
581 | @end smallexample |
582 | ||
583 | @noindent | |
584 | where the two extra numbers give the smallest and largest character | |
585 | position that point is allowed to assume. The characters between those | |
586 | two positions are the accessible ones. @xref{Narrowing}. | |
587 | ||
588 | If point is at the end of the buffer (or the end of the accessible | |
589 | part), the @w{@kbd{C-x =}} output does not describe a character after | |
590 | point. The output might look like this: | |
591 | ||
592 | @smallexample | |
fe7c712e | 593 | point=36169 of 36168 (EOB) column=0 |
6bf7aab6 DL |
594 | @end smallexample |
595 | ||
01005464 | 596 | @cindex character set of character at point |
7923e3c2 | 597 | @cindex font of character at point |
01005464 | 598 | @cindex text properties at point |
c7bda15b | 599 | @w{@kbd{C-u C-x =}} displays the following additional information about a |
27a132c3 KH |
600 | character. |
601 | ||
602 | @itemize @bullet | |
603 | @item | |
42a99593 | 604 | The character set name, and the codes that identify the character |
27a132c3 KH |
605 | within that character set; @acronym{ASCII} characters are identified |
606 | as belonging to the @code{ascii} character set. | |
607 | ||
608 | @item | |
609 | The character's syntax and categories. | |
610 | ||
611 | @item | |
42a99593 RS |
612 | The character's encodings, both internally in the buffer, and externally |
613 | if you were to save the file. | |
27a132c3 KH |
614 | |
615 | @item | |
411fe8f3 | 616 | What keys to type to input the character in the current input method |
42a99593 | 617 | (if it supports the character). |
27a132c3 KH |
618 | |
619 | @item | |
bbf0fec6 RS |
620 | If you are running Emacs on a graphical display, the font name and |
621 | glyph code for the character. If you are running Emacs on a text-only | |
622 | terminal, the code(s) sent to the terminal. | |
27a132c3 KH |
623 | |
624 | @item | |
625 | The character's text properties (@pxref{Text Properties,,, | |
6cf1bebc RS |
626 | elisp, the Emacs Lisp Reference Manual}), and any overlays containing it |
627 | (@pxref{Overlays,,, elisp, the same manual}). | |
27a132c3 KH |
628 | @end itemize |
629 | ||
6480c8b4 | 630 | Here's an example showing the Latin-1 character A with grave accent, |
27a132c3 | 631 | in a buffer whose coding system is @code{iso-latin-1}, whose |
6480c8b4 | 632 | terminal coding system is @code{iso-latin-1} (so the terminal actually |
01005464 EZ |
633 | displays the character as @samp{@`A}), and which has font-lock-mode |
634 | (@pxref{Font Lock}) enabled: | |
6bf7aab6 | 635 | |
9acb8eec | 636 | @smallexample |
fe7c712e | 637 | character: @`A (2240, #o4300, #x8c0, U+00C0) |
3f3015e4 | 638 | charset: latin-iso8859-1 |
27a132c3 | 639 | (Right-Hand Part of Latin Alphabet 1@dots{} |
3f3015e4 | 640 | code point: #x40 |
27a132c3 KH |
641 | syntax: w which means: word |
642 | category: l:Latin | |
3f3015e4 | 643 | to input: type "`A" with latin-1-prefix |
fe7c712e | 644 | buffer code: #x81 #xC0 |
3f3015e4 | 645 | file code: #xC0 (encoded by coding system iso-latin-1) |
fe7c712e | 646 | display: terminal code #xC0 |
27a132c3 KH |
647 | |
648 | There are text properties here: | |
649 | fontified t | |
9acb8eec | 650 | @end smallexample |
6bf7aab6 DL |
651 | |
652 | @node Arguments | |
653 | @section Numeric Arguments | |
654 | @cindex numeric arguments | |
655 | @cindex prefix arguments | |
4946337d | 656 | @cindex arguments to commands |
6bf7aab6 | 657 | |
411fe8f3 | 658 | In mathematics and computer usage, @dfn{argument} means |
6bf7aab6 DL |
659 | ``data provided to a function or operation.'' You can give any Emacs |
660 | command a @dfn{numeric argument} (also called a @dfn{prefix argument}). | |
661 | Some commands interpret the argument as a repetition count. For | |
662 | example, @kbd{C-f} with an argument of ten moves forward ten characters | |
663 | instead of one. With these commands, no argument is equivalent to an | |
664 | argument of one. Negative arguments tell most such commands to move or | |
665 | act in the opposite direction. | |
666 | ||
667 | @kindex M-1 | |
668 | @kindex M-@t{-} | |
669 | @findex digit-argument | |
670 | @findex negative-argument | |
1b53c26e RS |
671 | If your terminal keyboard has a @key{META} key (labeled @key{ALT} on |
672 | PC keyboards), the easiest way to specify a numeric argument is to | |
673 | type digits and/or a minus sign while holding down the @key{META} key. | |
674 | For example, | |
a1f6ea55 | 675 | |
6bf7aab6 DL |
676 | @example |
677 | M-5 C-n | |
678 | @end example | |
a1f6ea55 | 679 | |
6bf7aab6 | 680 | @noindent |
411fe8f3 | 681 | moves down five lines. The characters @kbd{Meta-1}, @kbd{Meta-2}, |
6bf7aab6 DL |
682 | and so on, as well as @kbd{Meta--}, do this because they are keys bound |
683 | to commands (@code{digit-argument} and @code{negative-argument}) that | |
411fe8f3 | 684 | are defined to set up an argument for the next command. |
a1f6ea55 EZ |
685 | @kbd{Meta--} without digits normally means @minus{}1. Digits and |
686 | @kbd{-} modified with Control, or Control and Meta, also specify numeric | |
687 | arguments. | |
6bf7aab6 DL |
688 | |
689 | @kindex C-u | |
690 | @findex universal-argument | |
411fe8f3 RS |
691 | You can also specify a numeric argument by typing @kbd{C-u} |
692 | (@code{universal-argument}) followed by the digits. The advantage of | |
693 | @kbd{C-u} is that you can type the digits without modifier keys; thus, | |
694 | @kbd{C-u} works on all terminals. For a negative argument, type a | |
695 | minus sign after @kbd{C-u}. A minus sign without digits normally | |
696 | means @minus{}1. | |
697 | ||
698 | @kbd{C-u} alone has the special meaning of | |
b96ade76 RS |
699 | ``four times'': it multiplies the argument for the next command by |
700 | four. @kbd{C-u C-u} multiplies it by sixteen. Thus, @kbd{C-u C-u | |
701 | C-f} moves forward sixteen characters. This is a good way to move | |
702 | forward ``fast,'' since it moves about 1/5 of a line in the usual size | |
703 | screen. Other useful combinations are @kbd{C-u C-n}, @kbd{C-u C-u | |
704 | C-n} (move down a good fraction of a screen), @kbd{C-u C-u C-o} (make | |
411fe8f3 | 705 | ``a lot'' of blank lines), and @kbd{C-u C-k} (kill four lines). |
6bf7aab6 | 706 | |
411fe8f3 RS |
707 | Some commands care whether there is an argument, but ignore its |
708 | value. For example, the command @kbd{M-q} (@code{fill-paragraph}) | |
709 | fills text; with an argument, it justifies the text as well. | |
710 | (@xref{Filling}, for more information on @kbd{M-q}.) Plain @kbd{C-u} | |
711 | is a handy way of providing an argument for such commands. | |
6bf7aab6 DL |
712 | |
713 | Some commands use the value of the argument as a repeat count, but do | |
714 | something peculiar when there is no argument. For example, the command | |
715 | @kbd{C-k} (@code{kill-line}) with argument @var{n} kills @var{n} lines, | |
716 | including their terminating newlines. But @kbd{C-k} with no argument is | |
717 | special: it kills the text up to the next newline, or, if point is right at | |
718 | the end of the line, it kills the newline itself. Thus, two @kbd{C-k} | |
719 | commands with no arguments can kill a nonblank line, just like @kbd{C-k} | |
720 | with an argument of one. (@xref{Killing}, for more information on | |
411fe8f3 | 721 | @kbd{C-k}.) |
6bf7aab6 DL |
722 | |
723 | A few commands treat a plain @kbd{C-u} differently from an ordinary | |
724 | argument. A few others may treat an argument of just a minus sign | |
725 | differently from an argument of @minus{}1. These unusual cases are | |
411fe8f3 RS |
726 | described when they come up; they exist to make an individual command |
727 | more convenient, and they are documented in that command's | |
728 | documentation string. | |
729 | ||
730 | You can use a numeric argument before a self-inserting character to | |
731 | insert multiple copies of it. This is straightforward when the | |
732 | character is not a digit; for example, @kbd{C-u 6 4 a} inserts 64 | |
733 | copies of the character @samp{a}. But this does not work for | |
734 | inserting digits; @kbd{C-u 6 4 1} specifies an argument of 641. You | |
735 | can separate the argument from the digit to insert with another | |
736 | @kbd{C-u}; for example, @kbd{C-u 6 4 C-u 1} does insert 64 copies of | |
737 | the character @samp{1}. | |
738 | ||
5a7f4c1b | 739 | We use the term ``prefix argument'' as well as ``numeric argument,'' |
411fe8f3 RS |
740 | to emphasize that you type these argument before the command, and to |
741 | distinguish them from minibuffer arguments that come after the | |
742 | command. | |
6bf7aab6 DL |
743 | |
744 | @node Repeating | |
745 | @section Repeating a Command | |
746 | @cindex repeating a command | |
747 | ||
9b3ae7e4 RS |
748 | Many simple commands, such as those invoked with a single key or |
749 | with @kbd{M-x @var{command-name} @key{RET}}, can be repeated by | |
750 | invoking them with a numeric argument that serves as a repeat count | |
751 | (@pxref{Arguments}). However, if the command you want to repeat | |
411fe8f3 RS |
752 | prompts for input, or uses a numeric argument in another way, that |
753 | method won't work. | |
68b7eaa9 | 754 | |
6bf7aab6 DL |
755 | @kindex C-x z |
756 | @findex repeat | |
757 | The command @kbd{C-x z} (@code{repeat}) provides another way to repeat | |
758 | an Emacs command many times. This command repeats the previous Emacs | |
759 | command, whatever that was. Repeating a command uses the same arguments | |
760 | that were used before; it does not read new arguments each time. | |
761 | ||
762 | To repeat the command more than once, type additional @kbd{z}'s: each | |
763 | @kbd{z} repeats the command one more time. Repetition ends when you | |
764 | type a character other than @kbd{z}, or press a mouse button. | |
765 | ||
766 | For example, suppose you type @kbd{C-u 2 0 C-d} to delete 20 | |
767 | characters. You can repeat that command (including its argument) three | |
768 | additional times, to delete a total of 80 characters, by typing @kbd{C-x | |
769 | z z z}. The first @kbd{C-x z} repeats the command once, and each | |
770 | subsequent @kbd{z} repeats it once again. | |
771 | ||
ab5796a9 MB |
772 | @ignore |
773 | arch-tag: cda8952a-c439-41c1-aecf-4bc0d6482956 | |
774 | @end ignore |