aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-07-31 19:29:50 +0000
committerChong Yidong2008-07-31 19:29:50 +0000
commit6c5f631991718f5db15d34804384f85c6738e04b (patch)
treed04142f9dfeb50bd16d16f46a78a460460b965ba
parent5f38310ad28209b8a7323c85e51b2aea4f93e47e (diff)
downloademacs-6c5f631991718f5db15d34804384f85c6738e04b.tar.gz
emacs-6c5f631991718f5db15d34804384f85c6738e04b.zip
(Inserting Text): Move DEL to deletion node.
(Moving Point): Add additional alternative key bindings. Describe line-move-visual. (Erasing): Describe DEL. (Basic Undo, Blank Lines, Arguments): Copyedit. (Continuation Lines): Mention Visual Line mode. (Position Info): Move extended discussion to mule.texi.
-rw-r--r--doc/emacs/basic.texi603
1 files changed, 268 insertions, 335 deletions
diff --git a/doc/emacs/basic.texi b/doc/emacs/basic.texi
index e1fa655f9b4..58ef0004d01 100644
--- a/doc/emacs/basic.texi
+++ b/doc/emacs/basic.texi
@@ -12,8 +12,6 @@ and save the text in a file. If this material is new to you, we
12suggest you first run the Emacs learn-by-doing tutorial, by typing 12suggest you first run the Emacs learn-by-doing tutorial, by typing
13@kbd{Control-h t} inside Emacs. (@code{help-with-tutorial}). 13@kbd{Control-h t} inside Emacs. (@code{help-with-tutorial}).
14 14
15 To clear and redisplay the screen, type @kbd{C-l} (@code{recenter}).
16
17@menu 15@menu
18 16
19* Inserting Text:: Inserting text by simply typing it. 17* Inserting Text:: Inserting text by simply typing it.
@@ -35,76 +33,45 @@ suggest you first run the Emacs learn-by-doing tutorial, by typing
35 33
36@cindex insertion 34@cindex insertion
37@cindex graphic characters 35@cindex graphic characters
38 Typing printing characters inserts them into the text you are 36 You can insert an ordinary @dfn{graphic character} (e.g., @samp{a},
39editing. It inserts them into the buffer at the cursor; more 37@samp{B}, @samp{3}, and @samp{=}) by typing the associated key. This
40precisely, it inserts them at @dfn{point}, but the cursor normally 38adds the character to the buffer at point. Insertion moves point
41shows where point is. @xref{Point}. 39forward, so that point remains just after the inserted text.
42 40@xref{Point}.
43 Insertion moves the cursor forward, and the following text moves
44forward with the cursor. If the text in the buffer is @samp{FOOBAR},
45with the cursor before the @samp{B}, and you type @kbd{XX}, you get
46@samp{FOOXXBAR}, with the cursor still before the @samp{B}.
47
48 To @dfn{delete} text you have just inserted, use the large key
49labeled @key{DEL}, @key{BACKSPACE} or @key{DELETE} which is a short
50distance above the @key{RET} or @key{ENTER} key. Regardless of the
51label on that key, Emacs thinks of it as @key{DEL}, and that's what we
52call it in this manual. @key{DEL} is the key you normally use outside
53Emacs to erase the last character that you typed.
54
55 The @key{DEL} key deletes the character @emph{before} the cursor.
56As a consequence, the cursor and all the characters after it move
57backwards. If you type a printing character and then type @key{DEL},
58they cancel out.
59
60 On most computers, Emacs sets up @key{DEL} automatically. In some
61cases, especially with text-only terminals, Emacs may guess wrong. If
62the key that ought to erase the last character doesn't do it in Emacs,
63see @ref{DEL Does Not Delete}.
64
65 Most PC keyboards have both a @key{BACKSPACE} key a little ways
66above @key{RET} or @key{ENTER}, and a @key{DELETE} key elsewhere. On
67these keyboards, Emacs tries to set up @key{BACKSPACE} as @key{DEL}.
68The @key{DELETE} key deletes ``forwards'' like @kbd{C-d} (see below),
69which means it deletes the character underneath the cursor (after
70point).
71 41
72@kindex RET 42@kindex RET
73@cindex newline 43@cindex newline
74 To end a line and start typing a new one, type @key{RET}. (This 44 To end a line and start a new one, type @key{RET}. This key may be
75key may be labeled @key{RETURN} or @key{ENTER}, but in Emacs we call 45labeled @key{Return} or @key{Enter} on your keyboard, but we refer to
76it @key{RET}.) This inserts a newline character in the buffer. If 46it as @key{RET} in this manual. Pressing it inserts a newline
77point is at the end of the line, this creates a new blank line after 47character in the buffer. If point is at the end of the line, this
78it. If point is in the middle of a line, the effect is to split that 48creates a new blank line after it; if point is in the middle of a
79line. Typing @key{DEL} when the cursor is at the beginning of a line 49line, the line is split at that position.
80deletes the preceding newline character, thus joining the line with 50
81the one before it. 51 As we explain later in this manual, you can change the way Emacs
82 52handles text insertion by turning on @dfn{minor modes}. For instance,
83 Emacs can split lines automatically when they become too long, if 53if you turn on a minor mode called @dfn{Auto Fill} mode, Emacs can
84you turn on a special minor mode called @dfn{Auto Fill} mode. 54split lines automatically when they become too long (@pxref{Filling}).
85@xref{Filling}, for Auto Fill mode and other methods of @dfn{filling} 55If you turn on a minor mode called @dfn{Overwrite} mode, inserted
86text. 56characters replace (overwrite) existing text, instead of shoving it to
87 57the right. @xref{Minor Modes}.
88 If you prefer printing characters to replace (overwrite) existing
89text, rather than shove it to the right, you should enable Overwrite
90mode, a minor mode. @xref{Minor Modes}.
91 58
92@cindex quoting 59@cindex quoting
93@kindex C-q 60@kindex C-q
94@findex quoted-insert 61@findex quoted-insert
95 Only printing characters and @key{SPC} insert themselves in Emacs. 62 Only graphic characters can be inserted by typing the associated
96Other characters act as editing commands and do not insert themselves. 63key; other keys act as editing commands and do not insert themselves.
97These include control characters, and characters with codes above 200 64For instance, @kbd{DEL} runs the command @code{delete-backward-char}
98octal. If you need to insert one of these characters in the buffer, 65by default (some modes bind it to a different command); it does not
99you must @dfn{quote} it by typing the character @kbd{Control-q} 66insert a literal @samp{DEL} character (@acronym{ASCII} character code
100(@code{quoted-insert}) first. (This character's name is normally 67127). To insert a non-graphic character, first @dfn{quote} it by
101written @kbd{C-q} for short.) There are two ways to use 68typing @kbd{C-q}. There are two ways to use @kbd{C-q}:
102@kbd{C-q}:
103 69
104@itemize @bullet 70@itemize @bullet
105@item 71@item
106@kbd{C-q} followed by any non-graphic character (even @kbd{C-g}) 72@kbd{C-q} followed by any non-graphic character (even @kbd{C-g})
107inserts that character. 73inserts that character. For instance, @kbd{C-q @key{DEL}} inserts a
74literal @samp{DEL} character.
108 75
109@item 76@item
110@kbd{C-q} followed by a sequence of octal digits inserts the character 77@kbd{C-q} followed by a sequence of octal digits inserts the character
@@ -121,13 +88,13 @@ of overwriting with it.
121 88
122@cindex 8-bit character codes 89@cindex 8-bit character codes
123@noindent 90@noindent
124When multibyte characters are enabled, if you specify a code in the 91If you specify a code in the octal range 0200 through 0377, @kbd{C-q}
125range 0200 through 0377 octal, @kbd{C-q} assumes that you intend to 92assumes that you intend to use some ISO 8859-@var{n} character set,
126use some ISO 8859-@var{n} character set, and converts the specified 93and converts the specified code to the corresponding Emacs character
127code to the corresponding Emacs character code. @xref{Enabling 94code. Your choice of language environment determines which of the ISO
128Multibyte}. You select @emph{which} of the ISO 8859 character sets to 958859 character sets to use (@pxref{Language Environments}). This
129use through your choice of language environment (@pxref{Language 96feature is disabled if multibyte characters are disabled
130Environments}). 97(@pxref{Enabling Multibyte}).
131 98
132@vindex read-quoted-char-radix 99@vindex read-quoted-char-radix
133To use decimal or hexadecimal instead of octal, set the variable 100To use decimal or hexadecimal instead of octal, set the variable
@@ -154,14 +121,16 @@ major modes rebind @key{DEL} to other commands.
154@cindex movement 121@cindex movement
155@cindex cursor motion 122@cindex cursor motion
156@cindex moving the cursor 123@cindex moving the cursor
157 To do more than insert characters, you have to know how to move point 124 To do more than insert characters, you have to know how to move
158(@pxref{Point}). The simplest way to do this is with arrow keys, or by 125point (@pxref{Point}). The keyboard commands @kbd{C-f}, @kbd{C-b},
159clicking the left mouse button where you want to move to. 126@kbd{C-n}, and @kbd{C-p} move point to the right, left, up and down
160 127respectively. These are equivalent to the commands @kbd{@key{right}},
161 There are also control and meta characters for cursor motion. Some 128@kbd{@key{left}}, @kbd{@key{down}}, and @kbd{@key{up}}, entered using
162are equivalent to the arrow keys (it is faster to use these control 129the @dfn{arrow keys} present on many keyboards. Many Emacs users find
163keys than move your hand over to the arrow keys). Others do more 130that it is slower to use the arrow keys than the equivalent control
164sophisticated things. 131keys. You can also click the left mouse button to move point to the
132position clicked. Emacs also provides a variety of additional
133keyboard commands that move point in more sophisticated ways.
165 134
166@kindex C-a 135@kindex C-a
167@kindex C-e 136@kindex C-e
@@ -189,28 +158,34 @@ sophisticated things.
189@findex move-to-window-line 158@findex move-to-window-line
190@table @kbd 159@table @kbd
191@item C-a 160@item C-a
161@itemx @key{Home}
192Move to the beginning of the line (@code{move-beginning-of-line}). 162Move to the beginning of the line (@code{move-beginning-of-line}).
193@item C-e 163@item C-e
164@itemx @key{End}
194Move to the end of the line (@code{move-end-of-line}). 165Move to the end of the line (@code{move-end-of-line}).
195@item C-f 166@item C-f
196Move forward one character (@code{forward-char}). The right-arrow key 167@itemx @key{right}
197does the same thing. 168Move forward one character (@code{forward-char}).
198@item C-b 169@item C-b
199Move backward one character (@code{backward-char}). The left-arrow 170@itemx @key{left}
200key has the same effect. 171Move backward one character (@code{backward-char}).
201@item M-f 172@item M-f
173@itemx M-@key{right}
174@itemx C-@key{right}
202Move forward one word (@code{forward-word}). 175Move forward one word (@code{forward-word}).
203@item M-b 176@item M-b
177@itemx M-@key{left}
178@itemx C-@key{left}
204Move backward one word (@code{backward-word}). 179Move backward one word (@code{backward-word}).
205@item C-n 180@item C-n
206Move down one line vertically (@code{next-line}). This command 181@itemx @key{down}
207attempts to keep the horizontal position unchanged, so if you start in 182Move down one screen line (@code{next-line}). This command attempts
208the middle of one line, you move to the middle of the next. The 183to keep the horizontal position unchanged, so if you start in the
209down-arrow key does the same thing. 184middle of one line, you move to the middle of the next.
210@item C-p 185@item C-p
211Move up one line, vertically (@code{previous-line}). The up-arrow key 186@itemx @key{up}
212has the same effect. This command preserves position within the line, 187Move up one screen line (@code{previous-line}). This command
213like @kbd{C-n}. 188preserves position within the line, like @kbd{C-n}.
214@item M-r 189@item M-r
215Move point to left margin, vertically centered in the window 190Move point to left margin, vertically centered in the window
216(@code{move-to-window-line}). Text does not move on the screen. 191(@code{move-to-window-line}). Text does not move on the screen.
@@ -225,31 +200,29 @@ numeric argument @var{n}, move to @var{n}/10 of the way from the top.
225@item M-> 200@item M->
226Move to the end of the buffer (@code{end-of-buffer}). 201Move to the end of the buffer (@code{end-of-buffer}).
227@item C-v 202@item C-v
228@itemx @key{PAGEDOWN} 203@itemx @key{PageDown}
229@itemx @key{PRIOR} 204@itemx @key{PRIOR}
230Scroll the display one screen forward, and move point if necessary to 205Scroll the display one screen forward, and move point if necessary to
231put it on the screen (@code{scroll-up}). This doesn't always move 206put it on the screen (@code{scroll-up}). If your keyboard has a
232point, but it is commonly used to do so. If your keyboard has a 207@key{PageDown} key (sometimes labelled @key{PRIOR}), it does the same
233@key{PAGEDOWN} or @key{PRIOR} key, it does the same thing. 208thing as as @key{C-v}. Scrolling commands are described further in
234 209@ref{Scrolling}.
235Scrolling commands are described further in @ref{Scrolling}.
236@item M-v 210@item M-v
237@itemx @key{PAGEUP} 211@itemx @key{PageUp}
238@itemx @key{NEXT} 212@itemx @key{NEXT}
239Scroll one screen backward, and move point if necessary to put it on 213Scroll one screen backward, and move point if necessary to put it on
240the screen (@code{scroll-down}). This doesn't always move point, but 214the screen (@code{scroll-down}). If your keyboard has a @key{PageUp}
241it is commonly used to do so. If your keyboard has a @key{PAGEUP} or 215key (sometimes labelled @key{NEXT}), it does the same thing as
242@key{NEXT} key, it does the same thing. 216@key{M-v}.
243@item M-x goto-char 217@item M-x goto-char
244Read a number @var{n} and move point to buffer position @var{n}. 218Read a number @var{n} and move point to buffer position @var{n}.
245Position 1 is the beginning of the buffer. 219Position 1 is the beginning of the buffer.
246@item M-g M-g 220@item M-g M-g
247@itemx M-g g 221@itemx M-g g
248@itemx M-x goto-line
249Read a number @var{n} and move point to the beginning of line number 222Read 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 223@var{n} (@code{goto-line}). Line 1 is the beginning of the buffer.
251just after a number in the buffer, and you type @key{RET} with the 224If point is on or just after a number in the buffer, and you type
252minibuffer empty, that number is used for @var{n}. 225@key{RET} with the minibuffer empty, that number is used for @var{n}.
253@item C-x C-n 226@item C-x C-n
254@findex set-goal-column 227@findex set-goal-column
255@kindex C-x C-n 228@kindex C-x C-n
@@ -263,11 +236,34 @@ Cancel the goal column. Henceforth, @kbd{C-n} and @kbd{C-p} try to
263preserve the horizontal position, as usual. 236preserve the horizontal position, as usual.
264@end table 237@end table
265 238
239@vindex line-move-visual
240 When a line of text in the buffer is longer than the width of the
241window, Emacs usually displays it on two or more @dfn{screen lines}.
242For convenience, @kbd{C-n} and @kbd{C-p} move point by screen lines,
243as do the equivalent keys @kbd{@key{down}} and @kbd{@key{up}}. You
244can force these commands to move according to @dfn{logical lines}
245(i.e., according to the text lines in the buffer) by setting the
246variable @code{line-move-visual} to @code{nil}; if a logical line
247occupies multiple screen lines, the cursor then skips over the
248additional screen lines. Moving by logical lines was the default
249behavior prior to Emacs 23.1. For details, see @ref{Continuation
250Lines}. @xref{Variables}, for how to set variables such as
251@code{line-move-visual}.
252
253 Unlike @kbd{C-n} and @kbd{C-p}, most of the Emacs commands that work
254on lines work on @emph{logical} lines. For instance, @kbd{C-a}
255(@code{move-beginning-of-line}) and @kbd{C-e}
256(@code{move-end-of-line}) respectively move to the beginning and end
257of the logical line. Whenever we encounter commands that work on
258screen lines, such as @kbd{C-n} and @kbd{C-p}, we will point these
259out.
260
266@vindex track-eol 261@vindex track-eol
267 If you set the variable @code{track-eol} to a non-@code{nil} value, 262 When @code{line-move-visual} is @code{nil}, you can also set the
268then @kbd{C-n} and @kbd{C-p}, when starting at the end of the line, move 263variable @code{track-eol} to a non-@code{nil} value. Then @kbd{C-n}
269to the end of another line. Normally, @code{track-eol} is @code{nil}. 264and @kbd{C-p}, when starting at the end of the logical line, move to
270@xref{Variables}, for how to set variables such as @code{track-eol}. 265the end of the next logical line. Normally, @code{track-eol} is
266@code{nil}.
271 267
272@vindex next-line-add-newlines 268@vindex next-line-add-newlines
273 @kbd{C-n} normally stops at the end of the buffer when you use it on 269 @kbd{C-n} normally stops at the end of the buffer when you use it on
@@ -281,15 +277,11 @@ moves down into it.
281 277
282@table @kbd 278@table @kbd
283@item @key{DEL} 279@item @key{DEL}
280@itemx @key{Backspace}
284Delete the character before point (@code{delete-backward-char}). 281Delete the character before point (@code{delete-backward-char}).
285@item C-d 282@item C-d
283@itemx @key{Delete}
286Delete the character after point (@code{delete-char}). 284Delete the character after point (@code{delete-char}).
287@item @key{DELETE}
288@itemx @key{BACKSPACE}
289One of these keys, whichever is the large key above the @key{RET} or
290@key{ENTER} key, deletes the character before point---it is @key{DEL}.
291If @key{BACKSPACE} is @key{DEL}, and your keyboard also has @key{DELETE},
292then @key{DELETE} deletes forwards, like @kbd{C-d}.
293@item C-k 285@item C-k
294Kill to the end of the line (@code{kill-line}). 286Kill to the end of the line (@code{kill-line}).
295@item M-d 287@item M-d
@@ -299,15 +291,29 @@ Kill back to the beginning of the previous word
299(@code{backward-kill-word}). 291(@code{backward-kill-word}).
300@end table 292@end table
301 293
294 The key @kbd{@key{DEL}} (@code{delete-backward-char}) removes the
295character before point, moving the cursor and all the characters after
296it backwards. On most keyboards, @key{DEL} is labelled
297@key{Backspace}, but we refer to it as @key{DEL} in this manual. Do
298not confuse @key{DEL} with another key, labelled @key{Delete}, that
299exists on many keyboards; we will discuss @key{Delete} momentarily.
300
301 Typing @key{DEL} when the cursor is at the beginning of a line
302deletes the preceding newline character, joining the line with the one
303before it.
304
305 On some text-only terminals, Emacs may not recognize the @key{DEL}
306key properly. If @key{DEL} does not do the right thing (e.g., if it
307deletes characters forwards), see @ref{DEL Does Not Delete}.
308
302@cindex killing characters and lines 309@cindex killing characters and lines
303@cindex deleting characters and lines 310@cindex deleting characters and lines
304@cindex erasing characters and lines 311@cindex erasing characters and lines
305 You already know about the @key{DEL} key which deletes the character 312 The key @kbd{C-d} (@code{delete-char}) deletes the character after
306before point (that is, before the cursor). Another key, @kbd{Control-d} 313point, i.e., the character under the cursor. This shifts the rest of
307(@kbd{C-d} for short), deletes the character after point (that is, the 314the text on the line to the left. If you type @kbd{C-d} at the end of
308character that the cursor is on). This shifts the rest of the text on 315a line, it joins that line with the following line. This command is
309the line to the left. If you type @kbd{C-d} at the end of a line, it 316also bound to the key labelled @key{Delete} on many keyboards.
310joins that line with the following line.
311 317
312 To erase a larger amount of text, use the @kbd{C-k} key, which 318 To erase a larger amount of text, use the @kbd{C-k} key, which
313erases (kills) a line at a time. If you type @kbd{C-k} at the 319erases (kills) a line at a time. If you type @kbd{C-k} at the
@@ -315,47 +321,47 @@ beginning or middle of a line, it kills all the text up to the end of
315the line. If you type @kbd{C-k} at the end of a line, it joins that 321the line. If you type @kbd{C-k} at the end of a line, it joins that
316line with the following line. 322line with the following line.
317 323
318 @xref{Killing}, for more flexible ways of killing text. 324 To learn more about killing text, see @ref{Killing}.
319 325
320@node Basic Undo 326@node Basic Undo
321@section Undoing Changes 327@section Undoing Changes
322 328
323 Emacs records a list of changes made in the buffer text, so you can
324undo recent changes, as far as the records go. Usually each editing
325command makes a separate entry in the undo records, but sometimes an
326entry covers just part of a command, and very simple commands may be
327grouped.
328
329@table @kbd 329@table @kbd
330@item C-x u 330@item C-/
331Undo one entry of the undo records---usually, one command worth 331Undo one entry of the undo records---usually, one command worth
332(@code{undo}). 332(@code{undo}).
333@itemx C-x u
333@item C-_ 334@item C-_
334@itemx C-/
335The same. 335The same.
336@end table 336@end table
337 337
338 The command @kbd{C-x u} (or @kbd{C-_} or @kbd{C-/}) is how you undo. 338 Emacs records a list of changes made in the buffer text, so you can
339Normally this command undoes the last change, and moves point back to 339undo recent changes. This is done using the @code{undo} command,
340where it was before the change. 340which is bound to @kbd{C-/} (as well as @kbd{C-x u} and @kbd{C-_}).
341Normally, this command undoes the last change, moving point back to
342where it was before the change. The undo command applies only to
343changes in the buffer; you can't use it to undo cursor motion.
344
345 Although each editing command usually makes a separate entry in the
346undo records, very simple commands may be grouped together.
347Sometimes, an entry may cover just part of a complex command.
341 348
342 If you repeat @kbd{C-x u} (or its aliases), each repetition undoes 349 If you repeat @kbd{C-/} (or its aliases), each repetition undoes
343another, earlier change, back to the limit of the undo information 350another, earlier change, back to the limit of the undo information
344available. If all recorded changes have already been undone, the undo 351available. If all recorded changes have already been undone, the undo
345command displays an error message and does nothing. 352command displays an error message and does nothing.
346 353
347 The undo command applies only to changes in the buffer; you can't 354 To learn more about the @code{undo} command, see @ref{Undo}.
348use it to undo mere cursor motion.
349 355
350@node Basic Files 356@node Basic Files
351@section Files 357@section Files
352 358
353 Text that you insert in an Emacs buffer lasts only as long as the 359 Text that you insert in an Emacs buffer lasts only as long as the
354Emacs session. To keep any text permanently you must put it in a 360Emacs session. To keep any text permanently, you must put it in a
355@dfn{file}. Files are named units of text which are stored by the 361@dfn{file}. Files are named units of text which are stored by the
356operating system for you to retrieve later by name. To use the 362operating system for you to retrieve later by name. To use the
357contents of a file in any way, you must specify the file name. That 363contents of a file in any way, including editing it with Emacs, you
358includes editing the file with Emacs. 364must specify the file name.
359 365
360 Suppose there is a file named @file{test.emacs} in your home 366 Suppose there is a file named @file{test.emacs} in your home
361directory. To begin editing this file in Emacs, type 367directory. To begin editing this file in Emacs, type
@@ -371,7 +377,7 @@ read the argument, and you type @key{RET} to terminate the argument
371(@pxref{Minibuffer}). 377(@pxref{Minibuffer}).
372 378
373 Emacs obeys this command by @dfn{visiting} the file: it creates a 379 Emacs obeys this command by @dfn{visiting} the file: it creates a
374buffer, it copies the contents of the file into the buffer, and then 380buffer, copies the contents of the file into the buffer, and then
375displays the buffer for editing. If you alter the text, you can 381displays the buffer for editing. If you alter the text, you can
376@dfn{save} the new text in the file by typing @kbd{C-x C-s} 382@dfn{save} the new text in the file by typing @kbd{C-x C-s}
377(@code{save-buffer}). This copies the altered buffer contents back 383(@code{save-buffer}). This copies the altered buffer contents back
@@ -392,7 +398,7 @@ first time you save this buffer with @kbd{C-x C-s}.
392@cindex getting help with keys 398@cindex getting help with keys
393 If you forget what a key does, you can find out with the Help 399 If you forget what a key does, you can find out with the Help
394character, which is @kbd{C-h} (or @key{F1}, which is an alias for 400character, which is @kbd{C-h} (or @key{F1}, which is an alias for
395@kbd{C-h}). Type @kbd{C-h k} followed by the key of interest; for 401@kbd{C-h}). Type @kbd{C-h k}, followed by the key of interest; for
396example, @kbd{C-h k C-n} tells you what @kbd{C-n} does. @kbd{C-h} is 402example, @kbd{C-h k C-n} tells you what @kbd{C-n} does. @kbd{C-h} is
397a prefix key; @kbd{C-h k} is just one of its subcommands (the command 403a prefix key; @kbd{C-h k} is just one of its subcommands (the command
398@code{describe-key}). The other subcommands of @kbd{C-h} provide 404@code{describe-key}). The other subcommands of @kbd{C-h} provide
@@ -409,7 +415,7 @@ blank lines.
409 415
410@table @kbd 416@table @kbd
411@item C-o 417@item C-o
412Insert one or more blank lines after the cursor (@code{open-line}). 418Insert a blank line after the cursor (@code{open-line}).
413@item C-x C-o 419@item C-x C-o
414Delete all but one of many consecutive blank lines 420Delete all but one of many consecutive blank lines
415(@code{delete-blank-lines}). 421(@code{delete-blank-lines}).
@@ -420,14 +426,12 @@ Delete all but one of many consecutive blank lines
420@cindex blank lines 426@cindex blank lines
421@findex open-line 427@findex open-line
422@findex delete-blank-lines 428@findex delete-blank-lines
423 To insert a new line of text before an existing line, 429 We have seen how @kbd{@key{RET}} (@code{newline}) starts a new line
424type the new line of text, followed by @key{RET}. 430of text. However, it may be easier to see what you are doing if you
425However, it may be easier to see what you are doing if you first make a 431first make a blank line and then insert the desired text into it.
426blank line and then insert the desired text into it. This is easy to do 432This is easy to do using the key @kbd{C-o} (@code{open-line}), which
427using the key @kbd{C-o} (@code{open-line}), which inserts a newline 433inserts a newline after point but leaves point in front of the
428after point but leaves point in front of the newline. After @kbd{C-o}, 434newline. After @kbd{C-o}, type the text for the new line.
429type the text for the new line. @kbd{C-o F O O} has the same effect as
430@w{@kbd{F O O @key{RET}}}, except for the final location of point.
431 435
432 You can make several blank lines by typing @kbd{C-o} several times, or 436 You can make several blank lines by typing @kbd{C-o} several times, or
433by giving it a numeric argument specifying how many blank lines to make. 437by giving it a numeric argument specifying how many blank lines to make.
@@ -436,10 +440,11 @@ command inserts the fill prefix on the new line, if typed at the
436beginning of a line. @xref{Fill Prefix}. 440beginning of a line. @xref{Fill Prefix}.
437 441
438 The easy way to get rid of extra blank lines is with the command 442 The easy way to get rid of extra blank lines is with the command
439@kbd{C-x C-o} (@code{delete-blank-lines}). @kbd{C-x C-o} in a run of 443@kbd{C-x C-o} (@code{delete-blank-lines}). If point lies within a run
440several blank lines deletes all but one of them. @kbd{C-x C-o} on a 444of several blank lines, @kbd{C-x C-o} deletes all but one of them. If
441lone blank line deletes that one. When point is on a nonblank line, 445point is on a single blank line, @kbd{C-x C-o} deletes it. If point
442@kbd{C-x C-o} deletes all following blank lines (if any). 446is on a nonblank line, @kbd{C-x C-o} deletes all following blank
447lines, if any exists.
443 448
444@node Continuation Lines 449@node Continuation Lines
445@section Continuation Lines 450@section Continuation Lines
@@ -448,37 +453,48 @@ lone blank line deletes that one. When point is on a nonblank line,
448@cindex wrapping 453@cindex wrapping
449@cindex line wrapping 454@cindex line wrapping
450@cindex fringes, and continuation lines 455@cindex fringes, and continuation lines
451 When a text line is too long to fit in one screen line, Emacs 456 Sometimes, a line of text in the buffer---a @dfn{logical line}---is
452displays it on two or more screen lines. This is called 457too long to fit in the window, and Emacs displays it as two or more
453@dfn{continuation} or @dfn{line wrapping}. On graphical displays, 458@dfn{screen lines}. This is called @dfn{line wrapping} or
454Emacs indicates line wrapping with small bent arrows in the left and 459@dfn{continuation}, and the long logical line is called a
455right window fringes. On text-only terminals, Emacs displays a 460@dfn{continued line}. On a graphical display, Emacs indicates line
456@samp{\} character at the right margin of a screen line if it is not 461wrapping with small bent arrows in the left and right window fringes.
457the last in its text line. This @samp{\} character says that the 462On a text-only terminal, Emacs indicates line wrapping by displaying a
458following screen line is not really a new text line. 463@samp{\} character at the right margin.
459 464
460 When line wrapping occurs just before a character that is wider than one 465 Most commands that act on lines act on logical lines, not screen
461column, some columns at the end of the previous screen line may be 466lines. For instance, @kbd{C-k} kills a logical line. As described
462``empty.'' In this case, Emacs displays additional @samp{\} 467earlier, @kbd{C-n} (@code{next-line}) and @kbd{C-p}
463characters in the ``empty'' columns before the @samp{\} 468(@code{previous-line}) are special exceptions: they move point down
464character that indicates continuation. 469and up, respectively, by one screen line (@pxref{Moving Point}).
465
466 Continued lines can be difficult to read, since lines can break in
467the middle of a word. If you prefer, you can make Emacs insert a
468newline automatically when a line gets too long, by using Auto Fill
469mode. Or enable Long Lines mode, which ensures that wrapping only
470occurs between words. @xref{Filling}.
471 470
472@cindex truncation 471@cindex truncation
473@cindex line truncation, and fringes 472@cindex line truncation, and fringes
474 Emacs can optionally @dfn{truncate} long lines---this means 473 Emacs can optionally @dfn{truncate} long logical lines instead of
475displaying just one screen line worth, and the rest of the long line 474continuing them. This means that every logical line occupies a single
476does not appear at all. @samp{$} in the last column or a small 475screen line; if it is longer than the width of the window, the rest of
477straight arrow in the window's right fringe indicates a truncated 476the line is not displayed. On a graphical display, a truncated line
478line. 477is indicated by a small straight arrow in the right fringe; on a
479 478text-only terminal, it is indicated by a @samp{$} character in the
480 @xref{Line Truncation}, for more about line truncation, 479right margin. @xref{Line Truncation}.
481and other variables that control how text is displayed. 480
481 By default, continued lines are wrapped at the right window edge.
482Since the wrapping may occur in the middle of a word, continued lines
483can be difficult to read. The usual solution is to break your lines
484before they get too long, by inserting newlines. If you prefer, you
485can make Emacs insert a newline automatically when a line gets too
486long, by using Auto Fill mode. @xref{Filling}.
487
488@cindex word wrap
489 Sometimes, you may need to edit files containing many long logical
490lines, and it may not be practical to break them all up by adding
491newlines. In that case, you can use Visual Line mode, which enables
492@dfn{word wrapping}: instead of wrapping long lines exactly at the
493right window edge, Emacs wraps them at the word boundaries (i.e.,
494space or tab characters) nearest to the right window edge. Visual
495Line mode also redefines editing commands such as @code{C-a},
496@code{C-n}, and @code{C-k} to operate on screen lines rather than
497logical lines. @xref{Visual Line Mode}.
482 498
483@node Position Info 499@node Position Info
484@section Cursor Position Information 500@section Cursor Position Information
@@ -515,13 +531,13 @@ Toggle automatic display of the size of the buffer.
515@cindex location of point 531@cindex location of point
516@cindex cursor location 532@cindex cursor location
517@cindex point location 533@cindex point location
518 @kbd{M-x what-line} displays the current line number 534 @kbd{M-x what-line} displays the current line number in the echo
519in the echo area. You can also see the current line number in the 535area. This command is usually redundant, because the current line
520mode line; see @ref{Mode Line}; but if you narrow the buffer, the 536number is shown in the mode line (@pxref{Mode Line}). However, if you
521line number in the mode line is relative to the accessible portion 537narrow the buffer, the mode line shows the the line number relative to
522(@pxref{Narrowing}). By contrast, @code{what-line} shows both the 538the accessible portion (@pxref{Narrowing}). By contrast,
523line number relative to the narrowed region and the line number 539@code{what-line} displays both the line number relative to the
524relative to the whole buffer. 540narrowed region and the line number relative to the whole buffer.
525 541
526 @kbd{M-x what-page} counts pages from the beginning of the file, and 542 @kbd{M-x what-page} counts pages from the beginning of the file, and
527counts lines within the page, showing both numbers in the echo area. 543counts lines within the page, showing both numbers in the echo area.
@@ -535,43 +551,31 @@ lines in the region (@pxref{Mark}). @xref{Pages}, for the command
535 551
536@kindex C-x = 552@kindex C-x =
537@findex what-cursor-position 553@findex what-cursor-position
538 The command @kbd{C-x =} (@code{what-cursor-position}) shows what 554 The command @kbd{C-x =} (@code{what-cursor-position}) shows
539cursor's column position, and other information about point and the 555information about the current cursor position and the buffer contents
540character after it. It displays a line in the echo area that looks 556at that position. It displays a line in the echo area that looks like
541like this: 557this:
542 558
543@smallexample 559@smallexample
544Char: c (99, #o143, #x63) point=28062 of 36168 (78%) column=53 560Char: c (99, #o143, #x63) point=28062 of 36168 (78%) column=53
545@end smallexample 561@end smallexample
546 562
547 The four values after @samp{Char:} describe the character that follows 563 After @samp{Char:}, this shows the character in the buffer at point.
548point, first by showing it and then by giving its character code in 564The text inside the parenthesis shows the corresponding decimal, octal
549decimal, octal and hex. For a non-@acronym{ASCII} multibyte character, these are 565and hex character codes; for more information about how @kbd{C-x =}
550followed by @samp{file} and the character's representation, in hex, in 566displays character information, see @ref{International Chars}. After
551the buffer's coding system, if that coding system encodes the character 567@samp{point=} is the position of point as a character count (the first
552safely and with a single byte (@pxref{Coding Systems}). If the 568character in the buffer is position 1, the second character is
553character's encoding is longer than one byte, Emacs shows @samp{file ...}. 569position 2, and so on). The number after that is the total number of
554 570characters in the buffer, and the number in parenthesis expresses the
555 However, if the character displayed is in the range 0200 through 571position as a percentage of the total. After @samp{column=} is the
5560377 octal, it may actually stand for an invalid UTF-8 byte read from 572horizontal position of point, in columns counting from the left edge
557a file. In Emacs, that byte is represented as a sequence of 8-bit 573of the window.
558characters, but all of them together display as the original invalid
559byte, in octal code. In this case, @kbd{C-x =} shows @samp{part of
560display ...} instead of @samp{file}.
561
562 @samp{point=} is followed by the position of point expressed as a
563character count. The start of the buffer is position 1, one character
564later is position 2, and so on. The next, larger, number is the total
565number of characters in the buffer. Afterward in parentheses comes
566the position expressed as a percentage of the total size.
567
568 @samp{column=} is followed by the horizontal position of point, in
569columns from the left edge of the window.
570 574
571 If the buffer has been narrowed, making some of the text at the 575 If the buffer has been narrowed, making some of the text at the
572beginning and the end temporarily inaccessible, @kbd{C-x =} displays 576beginning and the end temporarily inaccessible, @kbd{C-x =} displays
573additional text describing the currently accessible range. For example, it 577additional text describing the currently accessible range. For
574might display this: 578example, it might display this:
575 579
576@smallexample 580@smallexample
577Char: C (67, #o103, #x43) point=252 of 889 (28%) <231-599> column=0 581Char: C (67, #o103, #x43) point=252 of 889 (28%) <231-599> column=0
@@ -579,74 +583,8 @@ Char: C (67, #o103, #x43) point=252 of 889 (28%) <231-599> column=0
579 583
580@noindent 584@noindent
581where the two extra numbers give the smallest and largest character 585where the two extra numbers give the smallest and largest character
582position that point is allowed to assume. The characters between those 586position that point is allowed to assume. The characters between
583two positions are the accessible ones. @xref{Narrowing}. 587those two positions are the accessible ones. @xref{Narrowing}.
584
585 If point is at the end of the buffer (or the end of the accessible
586part), the @w{@kbd{C-x =}} output does not describe a character after
587point. The output might look like this:
588
589@smallexample
590point=36169 of 36168 (EOB) column=0
591@end smallexample
592
593@cindex character set of character at point
594@cindex font of character at point
595@cindex text properties at point
596@cindex face at point
597 @w{@kbd{C-u C-x =}} displays the following additional information about a
598character.
599
600@itemize @bullet
601@item
602The character set name, and the codes that identify the character
603within that character set; @acronym{ASCII} characters are identified
604as belonging to the @code{ascii} character set.
605
606@item
607The character's syntax and categories.
608
609@item
610The character's encodings, both internally in the buffer, and externally
611if you were to save the file.
612
613@item
614What keys to type to input the character in the current input method
615(if it supports the character).
616
617@item
618If you are running Emacs on a graphical display, the font name and
619glyph code for the character. If you are running Emacs on a text-only
620terminal, the code(s) sent to the terminal.
621
622@item
623The character's text properties (@pxref{Text Properties,,,
624elisp, the Emacs Lisp Reference Manual}), including any non-default
625faces used to display the character, and any overlays containing it
626(@pxref{Overlays,,, elisp, the same manual}).
627@end itemize
628
629 Here's an example showing the Latin-1 character A with grave accent,
630in a buffer whose coding system is @code{iso-latin-1}, whose
631terminal coding system is @code{iso-latin-1} (so the terminal actually
632displays the character as @samp{@`A}), and which has font-lock-mode
633(@pxref{Font Lock}) enabled:
634
635@smallexample
636 character: @`A (2240, #o4300, #x8c0, U+00C0)
637 charset: latin-iso8859-1
638 (Right-Hand Part of Latin Alphabet 1@dots{}
639 code point: #x40
640 syntax: w which means: word
641 category: l:Latin
642 to input: type "`A" with latin-1-prefix
643buffer code: #x81 #xC0
644 file code: #xC0 (encoded by coding system iso-latin-1)
645 display: terminal code #xC0
646
647There are text properties here:
648 fontified t
649@end smallexample
650 588
651@node Arguments 589@node Arguments
652@section Numeric Arguments 590@section Numeric Arguments
@@ -654,70 +592,74 @@ There are text properties here:
654@cindex prefix arguments 592@cindex prefix arguments
655@cindex arguments to commands 593@cindex arguments to commands
656 594
657 In mathematics and computer usage, @dfn{argument} means 595 In the terminology of mathematics and computing, @dfn{argument}
658``data provided to a function or operation.'' You can give any Emacs 596means ``data provided to a function or operation.'' You can give any
659command a @dfn{numeric argument} (also called a @dfn{prefix argument}). 597Emacs command a @dfn{numeric argument} (also called a @dfn{prefix
660Some commands interpret the argument as a repetition count. For 598argument}). Some commands interpret the argument as a repetition
661example, @kbd{C-f} with an argument of ten moves forward ten characters 599count. For example, giving @kbd{C-f} an argument of ten causes it to
662instead of one. With these commands, no argument is equivalent to an 600move point forward by ten characters instead of one. With these
663argument of one. Negative arguments tell most such commands to move or 601commands, no argument is equivalent to an argument of one, and
664act in the opposite direction. 602negative arguments cause them to move or act in the opposite
603direction.
665 604
666@kindex M-1 605@kindex M-1
667@kindex M-@t{-} 606@kindex M-@t{-}
668@findex digit-argument 607@findex digit-argument
669@findex negative-argument 608@findex negative-argument
670 If your terminal keyboard has a @key{META} key (labeled @key{ALT} on 609 The easiest way to specify a numeric argument is to type digits
671PC keyboards), the easiest way to specify a numeric argument is to 610and/or a minus sign while holding down the @key{META} key. For
672type digits and/or a minus sign while holding down the @key{META} key. 611example,
673For example,
674 612
675@example 613@example
676M-5 C-n 614M-5 C-n
677@end example 615@end example
678 616
679@noindent 617@noindent
680moves down five lines. The characters @kbd{Meta-1}, @kbd{Meta-2}, 618moves down five lines. The keys @kbd{M-1}, @kbd{M-2}, and so on, as
681and so on, as well as @kbd{Meta--}, do this because they are keys bound 619well as @kbd{M--}, are bound to commands (@code{digit-argument} and
682to commands (@code{digit-argument} and @code{negative-argument}) that 620@code{negative-argument}) that set up an argument for the next
683are defined to set up an argument for the next command. 621command. @kbd{Meta--} without digits normally means @minus{}1.
684@kbd{Meta--} without digits normally means @minus{}1. Digits and
685@kbd{-} modified with Control, or Control and Meta, also specify numeric
686arguments.
687 622
688@kindex C-u 623@kindex C-u
689@findex universal-argument 624@findex universal-argument
690 You can also specify a numeric argument by typing @kbd{C-u} 625 You can also specify a numeric argument by typing @kbd{C-u}
691(@code{universal-argument}) followed by the digits. The advantage of 626(@code{universal-argument}) followed by the digits. The advantage of
692@kbd{C-u} is that you can type the digits without modifier keys; thus, 627@kbd{C-u} is that you can type the digits without holding down the
693@kbd{C-u} works on all terminals. For a negative argument, type a 628@key{META} key. For a negative argument, type a minus sign after
694minus sign after @kbd{C-u}. A minus sign without digits normally 629@kbd{C-u}. A minus sign without digits normally means @minus{}1.
695means @minus{}1. 630
696 631 @kbd{C-u} alone has the special meaning of ``four times'': it
697 @kbd{C-u} alone has the special meaning of 632multiplies the argument for the next command by four. @kbd{C-u C-u}
698``four times'': it multiplies the argument for the next command by 633multiplies it by sixteen. Thus, @kbd{C-u C-u C-f} moves forward
699four. @kbd{C-u C-u} multiplies it by sixteen. Thus, @kbd{C-u C-u 634sixteen characters. Other useful combinations are @kbd{C-u C-n},
700C-f} moves forward sixteen characters. This is a good way to move 635@kbd{C-u C-u C-n} (move down a good fraction of a screen), @kbd{C-u
701forward ``fast,'' since it moves about 1/5 of a line in the usual size 636C-u C-o} (make ``a lot'' of blank lines), and @kbd{C-u C-k} (kill four
702screen. Other useful combinations are @kbd{C-u C-n}, @kbd{C-u C-u 637lines).
703C-n} (move down a good fraction of a screen), @kbd{C-u C-u C-o} (make 638
704``a lot'' of blank lines), and @kbd{C-u C-k} (kill four lines). 639 You can use a numeric argument before a self-inserting character to
640insert multiple copies of it. This is straightforward when the
641character is not a digit; for example, @kbd{C-u 6 4 a} inserts 64
642copies of the character @samp{a}. But this does not work for
643inserting digits; @kbd{C-u 6 4 1} specifies an argument of 641. You
644can separate the argument from the digit to insert with another
645@kbd{C-u}; for example, @kbd{C-u 6 4 C-u 1} does insert 64 copies of
646the character @samp{1}.
705 647
706 Some commands care whether there is an argument, but ignore its 648 Some commands care whether there is an argument, but ignore its
707value. For example, the command @kbd{M-q} (@code{fill-paragraph}) 649value. For example, the command @kbd{M-q} (@code{fill-paragraph})
708fills text; with an argument, it justifies the text as well. 650fills text; with an argument, it justifies the text as well.
709(@xref{Filling}, for more information on @kbd{M-q}.) Plain @kbd{C-u} 651(@xref{Filling}, for more information on @kbd{M-q}.) For these
710is a handy way of providing an argument for such commands. 652commands, it is enough to the argument with a single @kbd{C-u}.
711 653
712 Some commands use the value of the argument as a repeat count, but do 654 Some commands use the value of the argument as a repeat count, but
713something peculiar when there is no argument. For example, the command 655do something special when there is no argument. For example, the
714@kbd{C-k} (@code{kill-line}) with argument @var{n} kills @var{n} lines, 656command @kbd{C-k} (@code{kill-line}) with argument @var{n} kills
715including their terminating newlines. But @kbd{C-k} with no argument is 657@var{n} lines, including their terminating newlines. But @kbd{C-k}
716special: it kills the text up to the next newline, or, if point is right at 658with no argument is special: it kills the text up to the next newline,
717the end of the line, it kills the newline itself. Thus, two @kbd{C-k} 659or, if point is right at the end of the line, it kills the newline
718commands with no arguments can kill a nonblank line, just like @kbd{C-k} 660itself. Thus, two @kbd{C-k} commands with no arguments can kill a
719with an argument of one. (@xref{Killing}, for more information on 661nonblank line, just like @kbd{C-k} with an argument of one.
720@kbd{C-k}.) 662(@xref{Killing}, for more information on @kbd{C-k}.)
721 663
722 A few commands treat a plain @kbd{C-u} differently from an ordinary 664 A few commands treat a plain @kbd{C-u} differently from an ordinary
723argument. A few others may treat an argument of just a minus sign 665argument. A few others may treat an argument of just a minus sign
@@ -726,15 +668,6 @@ described when they come up; they exist to make an individual command
726more convenient, and they are documented in that command's 668more convenient, and they are documented in that command's
727documentation string. 669documentation string.
728 670
729 You can use a numeric argument before a self-inserting character to
730insert multiple copies of it. This is straightforward when the
731character is not a digit; for example, @kbd{C-u 6 4 a} inserts 64
732copies of the character @samp{a}. But this does not work for
733inserting digits; @kbd{C-u 6 4 1} specifies an argument of 641. You
734can separate the argument from the digit to insert with another
735@kbd{C-u}; for example, @kbd{C-u 6 4 C-u 1} does insert 64 copies of
736the character @samp{1}.
737
738 We use the term ``prefix argument'' as well as ``numeric argument,'' 671 We use the term ``prefix argument'' as well as ``numeric argument,''
739to emphasize that you type these argument before the command, and to 672to emphasize that you type these argument before the command, and to
740distinguish them from minibuffer arguments that come after the 673distinguish them from minibuffer arguments that come after the