1999-09-29 15:17:24 +00:00
|
|
|
@c This is part of the Emacs manual.
|
2005-08-10 15:40:54 +00:00
|
|
|
@c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2002, 2003,
|
|
|
|
@c 2004, 2005 Free Software Foundation, Inc.
|
1999-09-29 15:17:24 +00:00
|
|
|
@c See file emacs.texi for copying conditions.
|
2003-08-18 13:19:14 +00:00
|
|
|
@node Fixit, Keyboard Macros, Search, Top
|
1999-09-29 15:17:24 +00:00
|
|
|
@chapter Commands for Fixing Typos
|
|
|
|
@cindex typos, fixing
|
|
|
|
@cindex mistakes, correcting
|
|
|
|
|
|
|
|
In this chapter we describe the commands that are especially useful for
|
|
|
|
the times when you catch a mistake in your text just after you have made
|
|
|
|
it, or change your mind while composing text on the fly.
|
|
|
|
|
|
|
|
The most fundamental command for correcting erroneous editing is the
|
2005-02-25 13:45:59 +00:00
|
|
|
undo command, @kbd{C-x u} or @kbd{C-_} or @kbd{C-/}. This command
|
|
|
|
undoes a single command (usually), a part of a command (in the case of
|
|
|
|
@code{query-replace}), or several consecutive self-inserting
|
|
|
|
characters. Consecutive repetitions of the undo command undo earlier
|
|
|
|
and earlier changes, back to the limit of the undo information
|
|
|
|
available. @xref{Undo}, for more information.
|
1999-09-29 15:17:24 +00:00
|
|
|
|
|
|
|
@menu
|
|
|
|
* Kill Errors:: Commands to kill a batch of recently entered text.
|
|
|
|
* Transpose:: Exchanging two characters, words, lines, lists...
|
|
|
|
* Fixing Case:: Correcting case of last word entered.
|
|
|
|
* Spelling:: Apply spelling checker to a word, or a whole file.
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
@node Kill Errors
|
|
|
|
@section Killing Your Mistakes
|
|
|
|
|
|
|
|
@table @kbd
|
|
|
|
@item @key{DEL}
|
|
|
|
Delete last character (@code{delete-backward-char}).
|
|
|
|
@item M-@key{DEL}
|
|
|
|
Kill last word (@code{backward-kill-word}).
|
|
|
|
@item C-x @key{DEL}
|
|
|
|
Kill to beginning of sentence (@code{backward-kill-sentence}).
|
|
|
|
@end table
|
|
|
|
|
|
|
|
The @key{DEL} character (@code{delete-backward-char}) is the most
|
|
|
|
important correction command. It deletes the character before point.
|
|
|
|
When @key{DEL} follows a self-inserting character command, you can think
|
|
|
|
of it as canceling that command. However, avoid the mistake of thinking
|
|
|
|
of @key{DEL} as a general way to cancel a command!
|
|
|
|
|
|
|
|
When your mistake is longer than a couple of characters, it might be
|
|
|
|
more convenient to use @kbd{M-@key{DEL}} or @kbd{C-x @key{DEL}}.
|
|
|
|
@kbd{M-@key{DEL}} kills back to the start of the last word, and @kbd{C-x
|
|
|
|
@key{DEL}} kills back to the start of the last sentence. @kbd{C-x
|
|
|
|
@key{DEL}} is particularly useful when you change your mind about the
|
|
|
|
phrasing of the text you are writing. @kbd{M-@key{DEL}} and @kbd{C-x
|
|
|
|
@key{DEL}} save the killed text for @kbd{C-y} and @kbd{M-y} to
|
|
|
|
retrieve. @xref{Yanking}.@refill
|
|
|
|
|
|
|
|
@kbd{M-@key{DEL}} is often useful even when you have typed only a few
|
|
|
|
characters wrong, if you know you are confused in your typing and aren't
|
|
|
|
sure exactly what you typed. At such a time, you cannot correct with
|
|
|
|
@key{DEL} except by looking at the screen to see what you did. Often it
|
|
|
|
requires less thought to kill the whole word and start again.
|
|
|
|
|
|
|
|
@node Transpose
|
|
|
|
@section Transposing Text
|
|
|
|
|
|
|
|
@table @kbd
|
|
|
|
@item C-t
|
|
|
|
Transpose two characters (@code{transpose-chars}).
|
|
|
|
@item M-t
|
|
|
|
Transpose two words (@code{transpose-words}).
|
|
|
|
@item C-M-t
|
|
|
|
Transpose two balanced expressions (@code{transpose-sexps}).
|
|
|
|
@item C-x C-t
|
|
|
|
Transpose two lines (@code{transpose-lines}).
|
|
|
|
@end table
|
|
|
|
|
|
|
|
@kindex C-t
|
|
|
|
@findex transpose-chars
|
|
|
|
The common error of transposing two characters can be fixed, when they
|
|
|
|
are adjacent, with the @kbd{C-t} command (@code{transpose-chars}). Normally,
|
|
|
|
@kbd{C-t} transposes the two characters on either side of point. When
|
|
|
|
given at the end of a line, rather than transposing the last character of
|
|
|
|
the line with the newline, which would be useless, @kbd{C-t} transposes the
|
|
|
|
last two characters on the line. So, if you catch your transposition error
|
|
|
|
right away, you can fix it with just a @kbd{C-t}. If you don't catch it so
|
2001-08-25 20:44:44 +00:00
|
|
|
fast, you must move the cursor back between the two transposed
|
|
|
|
characters before you type @kbd{C-t}. If you transposed a space with
|
|
|
|
the last character of the word before it, the word motion commands are
|
|
|
|
a good way of getting there. Otherwise, a reverse search (@kbd{C-r})
|
|
|
|
is often the best way. @xref{Search}.
|
1999-09-29 15:17:24 +00:00
|
|
|
|
|
|
|
@kindex C-x C-t
|
|
|
|
@findex transpose-lines
|
|
|
|
@kindex M-t
|
|
|
|
@findex transpose-words
|
2001-02-21 15:29:46 +00:00
|
|
|
@c Don't index C-M-t and transpose-sexps here, they are indexed in
|
|
|
|
@c programs.texi, in the "List Commands" node.
|
|
|
|
@c @kindex C-M-t
|
|
|
|
@c @findex transpose-sexps
|
2001-04-01 03:20:52 +00:00
|
|
|
@kbd{M-t} transposes the word before point with the word after point
|
|
|
|
(@code{transpose-words}). It moves point forward over a word,
|
|
|
|
dragging the word preceding or containing point forward as well. The
|
|
|
|
punctuation characters between the words do not move. For example,
|
|
|
|
@w{@samp{FOO, BAR}} transposes into @w{@samp{BAR, FOO}} rather than
|
|
|
|
@samp{@w{BAR FOO,}}.
|
1999-09-29 15:17:24 +00:00
|
|
|
|
2001-06-26 13:21:07 +00:00
|
|
|
@kbd{C-M-t} (@code{transpose-sexps}) is a similar command for
|
|
|
|
transposing two expressions (@pxref{Expressions}), and @kbd{C-x C-t}
|
|
|
|
(@code{transpose-lines}) exchanges lines. They work like @kbd{M-t}
|
2001-08-08 23:39:08 +00:00
|
|
|
except as regards what units of text they transpose.
|
1999-09-29 15:17:24 +00:00
|
|
|
|
|
|
|
A numeric argument to a transpose command serves as a repeat count: it
|
2001-06-26 13:21:07 +00:00
|
|
|
tells the transpose command to move the character (word, expression, line)
|
1999-09-29 15:17:24 +00:00
|
|
|
before or containing point across several other characters (words,
|
2001-06-26 13:21:07 +00:00
|
|
|
expressions, lines). For example, @kbd{C-u 3 C-t} moves the character before
|
1999-09-29 15:17:24 +00:00
|
|
|
point forward across three other characters. It would change
|
|
|
|
@samp{f@point{}oobar} into @samp{oobf@point{}ar}. This is equivalent to
|
|
|
|
repeating @kbd{C-t} three times. @kbd{C-u - 4 M-t} moves the word
|
|
|
|
before point backward across four words. @kbd{C-u - C-M-t} would cancel
|
|
|
|
the effect of plain @kbd{C-M-t}.@refill
|
|
|
|
|
|
|
|
A numeric argument of zero is assigned a special meaning (because
|
|
|
|
otherwise a command with a repeat count of zero would do nothing): to
|
2001-06-26 13:21:07 +00:00
|
|
|
transpose the character (word, expression, line) ending after point
|
|
|
|
with the one ending after the mark.
|
1999-09-29 15:17:24 +00:00
|
|
|
|
|
|
|
@node Fixing Case
|
|
|
|
@section Case Conversion
|
|
|
|
|
|
|
|
@table @kbd
|
|
|
|
@item M-- M-l
|
|
|
|
Convert last word to lower case. Note @kbd{Meta--} is Meta-minus.
|
|
|
|
@item M-- M-u
|
|
|
|
Convert last word to all upper case.
|
|
|
|
@item M-- M-c
|
|
|
|
Convert last word to lower case with capital initial.
|
|
|
|
@end table
|
|
|
|
|
|
|
|
@kindex M-@t{-} M-l
|
|
|
|
@kindex M-@t{-} M-u
|
|
|
|
@kindex M-@t{-} M-c
|
|
|
|
A very common error is to type words in the wrong case. Because of this,
|
|
|
|
the word case-conversion commands @kbd{M-l}, @kbd{M-u} and @kbd{M-c} have a
|
|
|
|
special feature when used with a negative argument: they do not move the
|
|
|
|
cursor. As soon as you see you have mistyped the last word, you can simply
|
|
|
|
case-convert it and go on typing. @xref{Case}.@refill
|
|
|
|
|
|
|
|
@node Spelling
|
|
|
|
@section Checking and Correcting Spelling
|
|
|
|
@cindex spelling, checking and correcting
|
|
|
|
@cindex checking spelling
|
|
|
|
@cindex correcting spelling
|
|
|
|
|
|
|
|
This section describes the commands to check the spelling of a single
|
|
|
|
word or of a portion of a buffer. These commands work with the spelling
|
|
|
|
checker program Ispell, which is not part of Emacs.
|
|
|
|
@ifinfo
|
2004-04-18 20:04:24 +00:00
|
|
|
@xref{Top, Ispell, Overview ispell, ispell, The Ispell Manual}.
|
1999-09-29 15:17:24 +00:00
|
|
|
@end ifinfo
|
|
|
|
|
|
|
|
@table @kbd
|
|
|
|
@item M-x flyspell-mode
|
|
|
|
Enable Flyspell mode, which highlights all misspelled words.
|
2005-02-03 07:25:47 +00:00
|
|
|
@item M-x flyspell-prog-mode
|
2002-09-16 15:18:24 +00:00
|
|
|
Enable Flyspell mode for comments and strings only.
|
1999-09-29 15:17:24 +00:00
|
|
|
@item M-$
|
|
|
|
Check and correct spelling of the word at point (@code{ispell-word}).
|
|
|
|
@item M-@key{TAB}
|
2005-02-25 13:45:59 +00:00
|
|
|
@itemx @key{ESC} @key{TAB}
|
1999-09-29 15:17:24 +00:00
|
|
|
Complete the word before point based on the spelling dictionary
|
|
|
|
(@code{ispell-complete-word}).
|
2000-08-22 15:13:14 +00:00
|
|
|
@item M-x ispell
|
|
|
|
Spell-check the active region or the current buffer.
|
1999-09-29 15:17:24 +00:00
|
|
|
@item M-x ispell-buffer
|
|
|
|
Check and correct spelling of each word in the buffer.
|
|
|
|
@item M-x ispell-region
|
|
|
|
Check and correct spelling of each word in the region.
|
|
|
|
@item M-x ispell-message
|
2003-02-04 14:56:31 +00:00
|
|
|
Check and correct spelling of each word in a draft mail message,
|
1999-09-29 15:17:24 +00:00
|
|
|
excluding cited material.
|
|
|
|
@item M-x ispell-change-dictionary @key{RET} @var{dict} @key{RET}
|
|
|
|
Restart the Ispell process, using @var{dict} as the dictionary.
|
|
|
|
@item M-x ispell-kill-ispell
|
|
|
|
Kill the Ispell subprocess.
|
|
|
|
@end table
|
|
|
|
|
|
|
|
@cindex Flyspell mode
|
|
|
|
@findex flyspell-mode
|
|
|
|
Flyspell mode is a fully-automatic way to check spelling as you edit
|
|
|
|
in Emacs. It operates by checking words as you change or insert them.
|
|
|
|
When it finds a word that it does not recognize, it highlights that
|
|
|
|
word. This does not interfere with your editing, but when you see the
|
|
|
|
highlighted word, you can move to it and fix it. Type @kbd{M-x
|
|
|
|
flyspell-mode} to enable or disable this mode in the current buffer.
|
|
|
|
|
|
|
|
When Flyspell mode highlights a word as misspelled, you can click on
|
|
|
|
it with @kbd{Mouse-2} to display a menu of possible corrections and
|
|
|
|
actions. You can also correct the word by editing it manually in any
|
|
|
|
way you like.
|
|
|
|
|
2002-09-16 15:18:24 +00:00
|
|
|
@findex flyspell-prog-mode
|
|
|
|
Flyspell Prog mode works just like ordinary Flyspell mode, except that
|
|
|
|
it only checks words in comments and string constants. This feature
|
|
|
|
is useful for editing programs. Type @kbd{M-x flyspell-prog-mode} to
|
|
|
|
enable or disable this mode in the current buffer.
|
|
|
|
|
1999-09-29 15:17:24 +00:00
|
|
|
The other Emacs spell-checking features check or look up words when
|
2005-05-25 01:50:05 +00:00
|
|
|
you give an explicit command to do so.
|
1999-09-29 15:17:24 +00:00
|
|
|
|
|
|
|
@kindex M-$
|
|
|
|
@findex ispell-word
|
2005-05-25 01:50:05 +00:00
|
|
|
To check the spelling of the word around or before point, and
|
1999-09-29 15:17:24 +00:00
|
|
|
optionally correct it as well, use the command @kbd{M-$}
|
|
|
|
(@code{ispell-word}). If the word is not correct, the command offers
|
|
|
|
you various alternatives for what to do about it.
|
|
|
|
|
|
|
|
@findex ispell-buffer
|
|
|
|
@findex ispell-region
|
|
|
|
To check the entire current buffer, use @kbd{M-x ispell-buffer}. Use
|
|
|
|
@kbd{M-x ispell-region} to check just the current region. To check
|
|
|
|
spelling in an email message you are writing, use @kbd{M-x
|
2001-08-25 20:44:44 +00:00
|
|
|
ispell-message}; that command checks the whole buffer, except for
|
1999-09-29 15:17:24 +00:00
|
|
|
material that is indented or appears to be cited from other messages.
|
|
|
|
|
2000-08-22 15:13:14 +00:00
|
|
|
@findex ispell
|
|
|
|
@cindex spell-checking the active region
|
|
|
|
The @kbd{M-x ispell} command spell-checks the active region if the
|
|
|
|
Transient Mark mode is on (@pxref{Transient Mark}), otherwise it
|
|
|
|
spell-checks the current buffer.
|
|
|
|
|
1999-09-29 15:17:24 +00:00
|
|
|
Each time these commands encounter an incorrect word, they ask you
|
|
|
|
what to do. They display a list of alternatives, usually including
|
|
|
|
several ``near-misses''---words that are close to the word being
|
2001-08-25 20:44:44 +00:00
|
|
|
checked. Then you must type a single-character response. Here are
|
|
|
|
the valid responses:
|
1999-09-29 15:17:24 +00:00
|
|
|
|
|
|
|
@table @kbd
|
|
|
|
@item @key{SPC}
|
|
|
|
Skip this word---continue to consider it incorrect, but don't change it
|
|
|
|
here.
|
|
|
|
|
|
|
|
@item r @var{new} @key{RET}
|
2005-02-25 13:45:59 +00:00
|
|
|
Replace the word (just this time) with @var{new}. (The replacement
|
|
|
|
string will be rescanned for more spelling errors.)
|
1999-09-29 15:17:24 +00:00
|
|
|
|
|
|
|
@item R @var{new} @key{RET}
|
|
|
|
Replace the word with @var{new}, and do a @code{query-replace} so you
|
2005-02-25 13:45:59 +00:00
|
|
|
can replace it elsewhere in the buffer if you wish. (The replacements
|
|
|
|
will be rescanned for more spelling errors.)
|
1999-09-29 15:17:24 +00:00
|
|
|
|
|
|
|
@item @var{digit}
|
|
|
|
Replace the word (just this time) with one of the displayed
|
|
|
|
near-misses. Each near-miss is listed with a digit; type that digit to
|
|
|
|
select it.
|
|
|
|
|
|
|
|
@item a
|
|
|
|
Accept the incorrect word---treat it as correct, but only in this
|
|
|
|
editing session.
|
|
|
|
|
|
|
|
@item A
|
|
|
|
Accept the incorrect word---treat it as correct, but only in this
|
|
|
|
editing session and for this buffer.
|
|
|
|
|
|
|
|
@item i
|
|
|
|
Insert this word in your private dictionary file so that Ispell will
|
2001-08-25 20:44:44 +00:00
|
|
|
consider it correct from now on, even in future sessions.
|
1999-09-29 15:17:24 +00:00
|
|
|
|
|
|
|
@item u
|
2001-06-11 16:23:01 +00:00
|
|
|
Insert the lower-case version of this word in your private dic@-tion@-ary
|
1999-09-29 15:17:24 +00:00
|
|
|
file.
|
|
|
|
|
|
|
|
@item m
|
|
|
|
Like @kbd{i}, but you can also specify dictionary completion
|
|
|
|
information.
|
|
|
|
|
|
|
|
@item l @var{word} @key{RET}
|
|
|
|
Look in the dictionary for words that match @var{word}. These words
|
2001-08-25 20:44:44 +00:00
|
|
|
become the new list of ``near-misses''; you can select one of them as
|
|
|
|
the replacement by typing a digit. You can use @samp{*} in @var{word} as a
|
1999-09-29 15:17:24 +00:00
|
|
|
wildcard.
|
|
|
|
|
|
|
|
@item C-g
|
2005-02-25 13:45:59 +00:00
|
|
|
Quit interactive spell checking, leaving point at the word that was
|
|
|
|
being checked. You can restart checking again afterward with @kbd{C-u
|
|
|
|
M-$}.
|
1999-09-29 15:17:24 +00:00
|
|
|
|
|
|
|
@item X
|
|
|
|
Same as @kbd{C-g}.
|
|
|
|
|
|
|
|
@item x
|
|
|
|
Quit interactive spell checking and move point back to where it was
|
|
|
|
when you started spell checking.
|
|
|
|
|
|
|
|
@item q
|
|
|
|
Quit interactive spell checking and kill the Ispell subprocess.
|
|
|
|
|
|
|
|
@item C-l
|
|
|
|
Refresh the screen.
|
|
|
|
|
|
|
|
@item C-z
|
|
|
|
This key has its normal command meaning (suspend Emacs or iconify this
|
|
|
|
frame).
|
2005-02-25 13:45:59 +00:00
|
|
|
|
|
|
|
@item ?
|
|
|
|
Show the list of options.
|
1999-09-29 15:17:24 +00:00
|
|
|
@end table
|
|
|
|
|
|
|
|
@findex ispell-complete-word
|
|
|
|
The command @code{ispell-complete-word}, which is bound to the key
|
|
|
|
@kbd{M-@key{TAB}} in Text mode and related modes, shows a list of
|
|
|
|
completions based on spelling correction. Insert the beginning of a
|
2005-02-16 10:01:06 +00:00
|
|
|
word, and then type @kbd{M-@key{TAB}}; the command displays a
|
|
|
|
completion list window. (If your window manager intercepts
|
2005-03-06 17:18:43 +00:00
|
|
|
@kbd{M-@key{TAB}}, type @kbd{@key{ESC} @key{TAB}} or @kbd{C-M-i}.) To
|
|
|
|
choose one of the completions listed, click @kbd{Mouse-2} or
|
|
|
|
@kbd{Mouse-1} fast on it, or move the cursor there in the completions
|
|
|
|
window and type @key{RET}. @xref{Text Mode}.
|
1999-09-29 15:17:24 +00:00
|
|
|
|
|
|
|
@ignore
|
|
|
|
@findex reload-ispell
|
|
|
|
The first time you use any of the spell checking commands, it starts
|
|
|
|
an Ispell subprocess. The first thing the subprocess does is read your
|
|
|
|
private dictionary, which defaults to the file @file{~/ispell.words}.
|
|
|
|
Words that you ``insert'' with the @kbd{i} command are added to that
|
|
|
|
file, but not right away---only at the end of the interactive
|
|
|
|
replacement procedure. Use the @kbd{M-x reload-ispell} command to
|
|
|
|
reload your private dictionary if you edit the file outside of Ispell.
|
|
|
|
@end ignore
|
|
|
|
|
|
|
|
@cindex @code{ispell} program
|
|
|
|
@findex ispell-kill-ispell
|
|
|
|
Once started, the Ispell subprocess continues to run (waiting for
|
|
|
|
something to do), so that subsequent spell checking commands complete
|
|
|
|
more quickly. If you want to get rid of the Ispell process, use
|
|
|
|
@kbd{M-x ispell-kill-ispell}. This is not usually necessary, since the
|
|
|
|
process uses no time except when you do spelling correction.
|
|
|
|
|
|
|
|
@vindex ispell-dictionary
|
2002-08-15 20:29:19 +00:00
|
|
|
Ispell uses two dictionaries together for spell checking: the
|
|
|
|
standard dictionary and your private dictionary. The variable
|
|
|
|
@code{ispell-dictionary} specifies the file name to use for the
|
|
|
|
standard dictionary; a value of @code{nil} selects the default
|
|
|
|
dictionary. The command @kbd{M-x ispell-change-dictionary} sets this
|
|
|
|
variable and then restarts the Ispell subprocess, so that it will use
|
|
|
|
a different standard dictionary.
|
1999-09-29 15:17:24 +00:00
|
|
|
|
2002-06-04 16:32:55 +00:00
|
|
|
@vindex ispell-complete-word-dict
|
2002-08-15 20:29:19 +00:00
|
|
|
Ispell uses a separate dictionary for word completion. The variable
|
|
|
|
@code{ispell-complete-word-dict} specifies the file name of this
|
|
|
|
dictionary. The completion dictionary must be different because it
|
2004-08-13 01:27:30 +00:00
|
|
|
cannot use root and affix information. For some languages
|
2002-08-15 20:29:19 +00:00
|
|
|
there is a spell checking dictionary but no word completion
|
|
|
|
dictionary.
|
2003-09-01 15:45:59 +00:00
|
|
|
|
|
|
|
@ignore
|
|
|
|
arch-tag: 3359a443-96ed-448f-9f05-c8111ba8eac0
|
|
|
|
@end ignore
|