(Input methods): Some more keys useful in Chinese input methods.
[bpt/emacs.git] / man / fixit.texi
CommitLineData
6bf7aab6
DL
1@c This is part of the Emacs manual.
2@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
3@c See file emacs.texi for copying conditions.
4@node Fixit, Files, Search, Top
5@chapter Commands for Fixing Typos
6@cindex typos, fixing
7@cindex mistakes, correcting
8
9 In this chapter we describe the commands that are especially useful for
10the times when you catch a mistake in your text just after you have made
11it, or change your mind while composing text on the fly.
12
13 The most fundamental command for correcting erroneous editing is the
14undo command, @kbd{C-x u} or @kbd{C-_}. This command undoes a single
15command (usually), a part of a command (in the case of
16@code{query-replace}), or several consecutive self-inserting characters.
17Consecutive repetitions of @kbd{C-_} or @kbd{C-x u} undo earlier and
18earlier changes, back to the limit of the undo information available.
b9f152ce 19@xref{Undo}, for more information.
6bf7aab6
DL
20
21@menu
22* Kill Errors:: Commands to kill a batch of recently entered text.
23* Transpose:: Exchanging two characters, words, lines, lists...
24* Fixing Case:: Correcting case of last word entered.
25* Spelling:: Apply spelling checker to a word, or a whole file.
26@end menu
27
28@node Kill Errors
29@section Killing Your Mistakes
30
31@table @kbd
32@item @key{DEL}
33Delete last character (@code{delete-backward-char}).
34@item M-@key{DEL}
35Kill last word (@code{backward-kill-word}).
36@item C-x @key{DEL}
37Kill to beginning of sentence (@code{backward-kill-sentence}).
38@end table
39
40 The @key{DEL} character (@code{delete-backward-char}) is the most
41important correction command. It deletes the character before point.
42When @key{DEL} follows a self-inserting character command, you can think
43of it as canceling that command. However, avoid the mistake of thinking
44of @key{DEL} as a general way to cancel a command!
45
46 When your mistake is longer than a couple of characters, it might be
47more convenient to use @kbd{M-@key{DEL}} or @kbd{C-x @key{DEL}}.
48@kbd{M-@key{DEL}} kills back to the start of the last word, and @kbd{C-x
49@key{DEL}} kills back to the start of the last sentence. @kbd{C-x
50@key{DEL}} is particularly useful when you change your mind about the
51phrasing of the text you are writing. @kbd{M-@key{DEL}} and @kbd{C-x
52@key{DEL}} save the killed text for @kbd{C-y} and @kbd{M-y} to
53retrieve. @xref{Yanking}.@refill
54
55 @kbd{M-@key{DEL}} is often useful even when you have typed only a few
56characters wrong, if you know you are confused in your typing and aren't
57sure exactly what you typed. At such a time, you cannot correct with
58@key{DEL} except by looking at the screen to see what you did. Often it
59requires less thought to kill the whole word and start again.
60
61@node Transpose
62@section Transposing Text
63
64@table @kbd
65@item C-t
66Transpose two characters (@code{transpose-chars}).
67@item M-t
68Transpose two words (@code{transpose-words}).
69@item C-M-t
70Transpose two balanced expressions (@code{transpose-sexps}).
71@item C-x C-t
72Transpose two lines (@code{transpose-lines}).
73@end table
74
75@kindex C-t
76@findex transpose-chars
77 The common error of transposing two characters can be fixed, when they
78are adjacent, with the @kbd{C-t} command (@code{transpose-chars}). Normally,
79@kbd{C-t} transposes the two characters on either side of point. When
80given at the end of a line, rather than transposing the last character of
81the line with the newline, which would be useless, @kbd{C-t} transposes the
82last two characters on the line. So, if you catch your transposition error
83right away, you can fix it with just a @kbd{C-t}. If you don't catch it so
84fast, you must move the cursor back to between the two transposed
85characters. If you transposed a space with the last character of the word
86before it, the word motion commands are a good way of getting there.
87Otherwise, a reverse search (@kbd{C-r}) is often the best way.
88@xref{Search}.
89
90
91@kindex C-x C-t
92@findex transpose-lines
93@kindex M-t
94@findex transpose-words
4946337d
EZ
95@c Don't index C-M-t and transpose-sexps here, they are indexed in
96@c programs.texi, in the "List Commands" node.
97@c @kindex C-M-t
98@c @findex transpose-sexps
0a4fb541
RS
99 @kbd{M-t} transposes the word before point with the word after point
100(@code{transpose-words}). It moves point forward over a word,
101dragging the word preceding or containing point forward as well. The
102punctuation characters between the words do not move. For example,
103@w{@samp{FOO, BAR}} transposes into @w{@samp{BAR, FOO}} rather than
104@samp{@w{BAR FOO,}}.
6bf7aab6 105
d6921e35
RS
106 @kbd{C-M-t} (@code{transpose-sexps}) is a similar command for
107transposing two expressions (@pxref{Expressions}), and @kbd{C-x C-t}
108(@code{transpose-lines}) exchanges lines. They work like @kbd{M-t}
109except in determining the division of the text into syntactic units.
6bf7aab6
DL
110
111 A numeric argument to a transpose command serves as a repeat count: it
d6921e35 112tells the transpose command to move the character (word, expression, line)
6bf7aab6 113before or containing point across several other characters (words,
d6921e35 114expressions, lines). For example, @kbd{C-u 3 C-t} moves the character before
6bf7aab6
DL
115point forward across three other characters. It would change
116@samp{f@point{}oobar} into @samp{oobf@point{}ar}. This is equivalent to
117repeating @kbd{C-t} three times. @kbd{C-u - 4 M-t} moves the word
118before point backward across four words. @kbd{C-u - C-M-t} would cancel
119the effect of plain @kbd{C-M-t}.@refill
120
121 A numeric argument of zero is assigned a special meaning (because
122otherwise a command with a repeat count of zero would do nothing): to
d6921e35
RS
123transpose the character (word, expression, line) ending after point
124with the one ending after the mark.
6bf7aab6
DL
125
126@node Fixing Case
127@section Case Conversion
128
129@table @kbd
130@item M-- M-l
131Convert last word to lower case. Note @kbd{Meta--} is Meta-minus.
132@item M-- M-u
133Convert last word to all upper case.
134@item M-- M-c
135Convert last word to lower case with capital initial.
136@end table
137
138@kindex M-@t{-} M-l
139@kindex M-@t{-} M-u
140@kindex M-@t{-} M-c
141 A very common error is to type words in the wrong case. Because of this,
142the word case-conversion commands @kbd{M-l}, @kbd{M-u} and @kbd{M-c} have a
143special feature when used with a negative argument: they do not move the
144cursor. As soon as you see you have mistyped the last word, you can simply
145case-convert it and go on typing. @xref{Case}.@refill
146
147@node Spelling
148@section Checking and Correcting Spelling
149@cindex spelling, checking and correcting
150@cindex checking spelling
151@cindex correcting spelling
152
153 This section describes the commands to check the spelling of a single
154word or of a portion of a buffer. These commands work with the spelling
155checker program Ispell, which is not part of Emacs.
156@ifinfo
157@xref{Top, Ispell, Overview ispell, ispell.info, The Ispell Manual}.
158@end ifinfo
159
160@table @kbd
161@item M-x flyspell-mode
162Enable Flyspell mode, which highlights all misspelled words.
163@item M-$
164Check and correct spelling of the word at point (@code{ispell-word}).
165@item M-@key{TAB}
166Complete the word before point based on the spelling dictionary
167(@code{ispell-complete-word}).
342ed792
EZ
168@item M-x ispell
169Spell-check the active region or the current buffer.
6bf7aab6
DL
170@item M-x ispell-buffer
171Check and correct spelling of each word in the buffer.
172@item M-x ispell-region
173Check and correct spelling of each word in the region.
174@item M-x ispell-message
175Check and correct spelling of each word in a draft mail message,
176excluding cited material.
177@item M-x ispell-change-dictionary @key{RET} @var{dict} @key{RET}
178Restart the Ispell process, using @var{dict} as the dictionary.
179@item M-x ispell-kill-ispell
180Kill the Ispell subprocess.
181@end table
182
183@cindex Flyspell mode
184@findex flyspell-mode
185 Flyspell mode is a fully-automatic way to check spelling as you edit
186in Emacs. It operates by checking words as you change or insert them.
187When it finds a word that it does not recognize, it highlights that
188word. This does not interfere with your editing, but when you see the
189highlighted word, you can move to it and fix it. Type @kbd{M-x
190flyspell-mode} to enable or disable this mode in the current buffer.
191
192 When Flyspell mode highlights a word as misspelled, you can click on
193it with @kbd{Mouse-2} to display a menu of possible corrections and
194actions. You can also correct the word by editing it manually in any
195way you like.
196
197 The other Emacs spell-checking features check or look up words when
198you give an explicit command to do so. Checking all or part of the
199buffer is useful when you have text that was written outside of this
200Emacs session and might contain any number of misspellings.
201
202@kindex M-$
203@findex ispell-word
204 To check the spelling of the word around or next to point, and
205optionally correct it as well, use the command @kbd{M-$}
206(@code{ispell-word}). If the word is not correct, the command offers
207you various alternatives for what to do about it.
208
209@findex ispell-buffer
210@findex ispell-region
211 To check the entire current buffer, use @kbd{M-x ispell-buffer}. Use
212@kbd{M-x ispell-region} to check just the current region. To check
213spelling in an email message you are writing, use @kbd{M-x
214ispell-message}; that checks the whole buffer, but does not check
215material that is indented or appears to be cited from other messages.
216
342ed792
EZ
217@findex ispell
218@cindex spell-checking the active region
219 The @kbd{M-x ispell} command spell-checks the active region if the
220Transient Mark mode is on (@pxref{Transient Mark}), otherwise it
221spell-checks the current buffer.
222
6bf7aab6
DL
223 Each time these commands encounter an incorrect word, they ask you
224what to do. They display a list of alternatives, usually including
225several ``near-misses''---words that are close to the word being
226checked. Then you must type a character. Here are the valid responses:
227
228@table @kbd
229@item @key{SPC}
230Skip this word---continue to consider it incorrect, but don't change it
231here.
232
233@item r @var{new} @key{RET}
234Replace the word (just this time) with @var{new}.
235
236@item R @var{new} @key{RET}
237Replace the word with @var{new}, and do a @code{query-replace} so you
238can replace it elsewhere in the buffer if you wish.
239
240@item @var{digit}
241Replace the word (just this time) with one of the displayed
242near-misses. Each near-miss is listed with a digit; type that digit to
243select it.
244
245@item a
246Accept the incorrect word---treat it as correct, but only in this
247editing session.
248
249@item A
250Accept the incorrect word---treat it as correct, but only in this
251editing session and for this buffer.
252
253@item i
254Insert this word in your private dictionary file so that Ispell will
255consider it correct it from now on, even in future sessions.
256
257@item u
a5a82fc3 258Insert the lower-case version of this word in your private dic@-tion@-ary
6bf7aab6
DL
259file.
260
261@item m
262Like @kbd{i}, but you can also specify dictionary completion
263information.
264
265@item l @var{word} @key{RET}
266Look in the dictionary for words that match @var{word}. These words
267become the new list of ``near-misses''; you can select one of them to
268replace with by typing a digit. You can use @samp{*} in @var{word} as a
269wildcard.
270
271@item C-g
272Quit interactive spell checking. You can restart it again afterward
273with @kbd{C-u M-$}.
274
275@item X
276Same as @kbd{C-g}.
277
278@item x
279Quit interactive spell checking and move point back to where it was
280when you started spell checking.
281
282@item q
283Quit interactive spell checking and kill the Ispell subprocess.
284
285@item C-l
286Refresh the screen.
287
288@item C-z
289This key has its normal command meaning (suspend Emacs or iconify this
290frame).
291@end table
292
293@findex ispell-complete-word
294 The command @code{ispell-complete-word}, which is bound to the key
295@kbd{M-@key{TAB}} in Text mode and related modes, shows a list of
296completions based on spelling correction. Insert the beginning of a
297word, and then type @kbd{M-@key{TAB}}; the command displays a completion
298list window. To choose one of the completions listed, click
299@kbd{Mouse-2} on it, or move the cursor there in the completions window
300and type @key{RET}. @xref{Text Mode}.
301
302@ignore
303@findex reload-ispell
304 The first time you use any of the spell checking commands, it starts
305an Ispell subprocess. The first thing the subprocess does is read your
306private dictionary, which defaults to the file @file{~/ispell.words}.
307Words that you ``insert'' with the @kbd{i} command are added to that
308file, but not right away---only at the end of the interactive
309replacement procedure. Use the @kbd{M-x reload-ispell} command to
310reload your private dictionary if you edit the file outside of Ispell.
311@end ignore
312
313@cindex @code{ispell} program
314@findex ispell-kill-ispell
315 Once started, the Ispell subprocess continues to run (waiting for
316something to do), so that subsequent spell checking commands complete
317more quickly. If you want to get rid of the Ispell process, use
318@kbd{M-x ispell-kill-ispell}. This is not usually necessary, since the
319process uses no time except when you do spelling correction.
320
321@vindex ispell-dictionary
322 Ispell uses two dictionaries: the standard dictionary and your private
323dictionary. The variable @code{ispell-dictionary} specifies the file
324name of the standard dictionary to use. A value of @code{nil} says to
325use the default dictionary. The command @kbd{M-x
326ispell-change-dictionary} sets this variable and then restarts the
327Ispell subprocess, so that it will use a different dictionary.
328