fixit.texi 7.0 KB

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