git-for-steve tweaks.
[sxemacs] / info / sxemacs / fixit.texi
1 @node Fixit, Files, Search, Top
2 @chapter Commands for Fixing Typos
3 @cindex typos
4 @cindex mistakes, correcting
5
6   This chapter describes commands that are especially useful when you
7 catch a mistake in your text just after you have made it, or when you
8 change your mind while composing text on line.
9
10 @menu
11 * Kill Errors:: Commands to kill a batch of recently entered text.
12 * Transpose::   Exchanging two characters, words, lines, lists...
13 * Fixing Case:: Correcting case of last word entered.
14 * Spelling::    Apply spelling checker to a word, or a whole file.
15 @end menu
16
17 @node Kill Errors, Transpose, Fixit, Fixit
18 @section Killing Your Mistakes
19
20 @table @kbd
21 @item @key{DEL}
22 Delete last character (@code{delete-backward-char}).
23 @item M-@key{DEL}
24 Kill last word (@code{backward-kill-word}).
25 @item C-x @key{DEL}
26 Kill to beginning of sentence (@code{backward-kill-sentence}).
27 @end table
28
29 @kindex DEL
30 @findex delete-backward-char
31   The @key{DEL} character (@code{delete-backward-char}) is the most
32 important correction command.  When used among graphic (self-inserting)
33 characters, it can be thought of as canceling the last character typed.
34
35 @kindex M-DEL
36 @kindex C-x DEL
37 @findex backward-kill-word
38 @findex backward-kill-sentence
39   When your mistake is longer than a couple of characters, it might be more
40 convenient to use @kbd{M-@key{DEL}} or @kbd{C-x @key{DEL}}.
41 @kbd{M-@key{DEL}} kills back to the start of the last word, and @kbd{C-x
42 @key{DEL}} kills back to the start of the last sentence.  @kbd{C-x
43 @key{DEL}} is particularly useful when you are thinking of what to write as
44 you type it, in case you change your mind about phrasing.
45 @kbd{M-@key{DEL}} and @kbd{C-x @key{DEL}} save the killed text for
46 @kbd{C-y} and @kbd{M-y} to retrieve.  @xref{Yanking}.@refill
47
48   @kbd{M-@key{DEL}} is often useful even when you have typed only a few
49 characters wrong, if you know you are confused in your typing and aren't
50 sure exactly what you typed.  At such a time, you cannot correct with
51 @key{DEL} except by looking at the screen to see what you did.  It requires
52 less thought to kill the whole word and start over.
53
54 @node Transpose, Fixing Case, Kill Errors, Fixit
55 @section Transposing Text
56
57 @table @kbd
58 @item C-t
59 Transpose two characters (@code{transpose-chars}).
60 @item M-t
61 Transpose two words (@code{transpose-words}).
62 @item C-M-t
63 Transpose two balanced expressions (@code{transpose-sexps}).
64 @item C-x C-t
65 Transpose two lines (@code{transpose-lines}).
66 @end table
67
68 @cindex transposition
69 @kindex C-t
70 @findex transpose-chars
71   The common error of transposing two adjacent characters can be fixed
72 with the @kbd{C-t} command (@code{transpose-chars}).  Normally,
73 @kbd{C-t} transposes the two characters on either side of point.  When
74 given at the end of a line, @kbd{C-t} transposes the last two characters
75 on the line, rather than transposing the last character of the line with
76 the newline, which would be useless.  If you catch a
77 transposition error right away, you can fix it with just @kbd{C-t}.
78 If you catch the error later,  move the cursor back to between
79 the two transposed characters.  If you transposed a space with the last
80 character of the word before it, the word motion commands are a good way
81 of getting there.  Otherwise, a reverse search (@kbd{C-r}) is often the
82 best way.  @xref{Search}.
83
84 @kindex C-x C-t
85 @findex transpose-lines
86 @kindex M-t
87 @findex transpose-words
88 @kindex C-M-t
89 @findex transpose-sexps
90   @kbd{Meta-t} (@code{transpose-words}) transposes the word before point
91 with the word after point.  It moves point forward over a word, dragging
92 the word preceding or containing point forward as well.  The punctuation
93 characters between the words do not move.  For example, @w{@samp{FOO, BAR}}
94 transposes into @w{@samp{BAR, FOO}} rather than @samp{@w{BAR FOO,}}.
95
96   @kbd{C-M-t} (@code{transpose-sexps}) is a similar command for transposing
97 two expressions (@pxref{Lists}), and @kbd{C-x C-t} (@code{transpose-lines})
98 exchanges lines.  It works like @kbd{M-t} but in determines the
99 division of the text into syntactic units differently.
100
101   A numeric argument to a transpose command serves as a repeat count: it
102 tells the transpose command to move the character (word, sexp, line) before
103 or containing point across several other characters (words, sexps, lines).
104 For example, @kbd{C-u 3 C-t} moves the character before point forward
105 across three other characters.  This is equivalent to repeating @kbd{C-t}
106 three times.  @kbd{C-u - 4 M-t} moves the word before point backward across
107 four words.  @kbd{C-u - C-M-t} would cancel the effect of plain
108 @kbd{C-M-t}.@refill
109
110   A numeric argument of zero transposes the character (word, sexp, line)
111 ending after point with the one ending after the mark (otherwise a
112 command with a repeat count of zero would do nothing).
113
114 @node Fixing Case, Spelling, Transpose, Fixit
115 @section Case Conversion
116
117 @table @kbd
118 @item M-- M-l
119 Convert last word to lower case.  Note that @kbd{Meta--} is ``Meta-minus.''
120 @item M-- M-u
121 Convert last word to all upper case.
122 @item M-- M-c
123 Convert last word to lower case with capital initial.
124 @end table
125
126 @findex downcase-word
127 @findex upcase-word
128 @findex capitalize-word
129 @kindex M-@t{-} M-l
130 @kindex M-@t{-} M-u
131 @kindex M-@t{-} M-c
132 @cindex case conversion
133 @cindex words
134   A  common error is to type words in the wrong case.  Because of this,
135 the word case-conversion commands @kbd{M-l}, @kbd{M-u}, and @kbd{M-c} do
136 not move the cursor when used with a negative argument.
137 As soon as you see you have mistyped the last word, you can simply
138 case-convert it and continue typing.  @xref{Case}.@refill
139
140 @node Spelling,, Fixing Case, Fixit
141 @section Checking and Correcting Spelling
142 @cindex spelling
143
144 @c doublewidecommands
145 @table @kbd
146 @item M-$
147 Check and correct spelling of word (@code{spell-word}).
148 @item M-x spell-buffer
149 Check and correct spelling of each word in the buffer.
150 @item M-x spell-region
151 Check and correct spelling of each word in the region.
152 @item M-x spell-string
153 Check spelling of specified word.
154 @end table
155
156 @kindex M-$
157 @findex spell-word
158   To check the spelling of the word before point, and optionally correct
159 it, use the command @kbd{M-$} (@code{spell-word}).  This command runs an
160 inferior process containing the @code{spell} program to see whether the
161 word is correct English.  If it is not, it asks you to edit the word (in
162 the minibuffer) into a corrected spelling, and then performs a
163 @code{query-replace} to substitute the corrected spelling for the old
164 one throughout the buffer.
165
166   If you exit the minibuffer without altering the original spelling, it
167 means you do not want to do anything to that word.  In that case, the
168 @code{query-replace} is not done.
169
170 @findex spell-buffer
171   @kbd{M-x spell-buffer} checks each word in the buffer the same way that
172 @code{spell-word} does, doing a @code{query-replace} for
173 every incorrect word if appropriate.@refill
174
175 @findex spell-region
176   @kbd{M-x spell-region} is similar to @code{spell-buffer} but operates
177 only on the region, not the entire buffer.
178
179 @findex spell-string
180   @kbd{M-x spell-string} reads a string as an argument and checks
181 whether that is a correctly spelled English word.  It prints a message
182 giving the answer in the echo area.