This section describes the commands to check the spelling of a single word or of a portion of a buffer. These commands only work if a spelling checker program, one of Hunspell, Aspell, Ispell or Enchant, is installed. These programs are not part of Emacs, but one of them is usually installed on GNU/Linux and other free operating systems. See Aspell in The Aspell Manual.
If you have only one of the spelling checker programs installed,
Emacs will find it when you invoke for the first time one of the
commands described here. If you have more than one of them installed,
you can control which one is used by customizing the variable
ispell-program-name
.
Check and correct spelling of the word at point (ispell-word
).
If the region is active, do it for all words in the region instead.
If a previous spelling operation was interrupted, continue that
operation (ispell-continue
).
Check and correct spelling of all words in the buffer. If the region is active, do it for all words in the region instead.
Check and correct spelling in the buffer.
Check and correct spelling in the region.
Check and correct spelling in a draft mail message, excluding cited material.
Check and correct spelling of comments and strings in the buffer or region.
Check the comment or string at point.
Restart the spell-checker process, using dict as the dictionary.
Kill the spell-checker subprocess.
Complete the word before point based on the spelling dictionary
(ispell-complete-word
).
Enable Flyspell mode, which highlights all misspelled words.
Enable Flyspell mode for comments and strings only.
To check the spelling of the word around or before point, and
optionally correct it as well, type M-$ (ispell-word
).
If a region is active, M-$ checks the spelling of all words
within the region. See The Mark and the Region. (When Transient Mark mode is off,
M-$ always acts on the word around or before point, ignoring the
region; see Disabling Transient Mark Mode.) When invoked with a prefix
argument, C-u M-$, this calls ispell-continue
, which
continues the spelling operation, if any, which was interrupted with
X or C-g.
Similarly, the command M-x ispell performs spell-checking in the region if one is active, or in the entire buffer otherwise. The commands M-x ispell-buffer and M-x ispell-region explicitly perform spell-checking on the entire buffer or the region respectively. To check spelling in an email message you are writing, use M-x ispell-message; that command checks the whole buffer, except for material that is indented or appears to be cited from other messages. See Sending Mail. When dealing with source code, you can use M-x ispell-comments-and-strings or M-x ispell-comment-or-string-at-point to check only comments or string literals.
When one of these commands encounters what appears to be an incorrect word, it asks you what to do. It usually displays a list of numbered near-misses—words that are close to the incorrect word. Then you must type a single-character response. Here are the valid responses:
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.
Skip this word—continue to consider it incorrect, but don’t change it here.
Replace the word, just this time, with new. (The replacement string will be rescanned for more spelling errors.)
Replace the word with new, and do a query-replace
so you
can replace it elsewhere in the buffer if you wish. (The replacements
will be rescanned for more spelling errors.)
Accept the incorrect word—treat it as correct, but only in this editing session.
Accept the incorrect word—treat it as correct, but only in this editing session and for this buffer.
Insert this word in your private dictionary file so that it will be considered correct from now on, even in future sessions.
Like i, but you can also specify dictionary completion information.
Insert the lower-case version of this word in your private dictionary file.
Look in the dictionary for words that match word. These words become the new list of near-misses; you can select one of them as the replacement by typing a digit. You can use ‘*’ in word as a wildcard.
Interrupt the interactive spell-checking, leaving point at the word that was being checked. You can restart checking again afterward with C-u M-$.
Quit interactive spell-checking and move point back to where it was when you started spell-checking.
Quit interactive spell-checking and kill the spell-checker subprocess.
Enter recursive-edit (see Recursive Editing Levels). When you exit recursive-edit with C-M-c, the interactive spell-checking will resume. This allows you to consult the buffer text without interrupting the spell-checking. Do not modify the buffer in the recursive editing, and especially don’t modify the misspelled word, as the edits will be undone when you exit recursive-edit. If you need to edit the misspelled word, use r or R instead, or use X, edit the buffer, then resume with C-u M-$.
Suspend Emacs or iconify the selected frame.
Show the list of options.
In Text mode and related modes, M-TAB
(ispell-complete-word
) performs in-buffer completion based on
spelling correction. Insert the beginning of a word, and then type
M-TAB; this shows a list of completions. (If your
window manager intercepts M-TAB, type ESC TAB or C-M-i.) Each completion is listed with a digit or
character; type that digit or character to choose it.
Once started, the spell-checker 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 process, use M-x ispell-kill-ispell. This is not usually necessary, since the process uses no processor time except when you do spelling correction.
Spell-checkers look up spelling in two dictionaries:
the standard dictionary and your personal dictionary. The standard
dictionary is specified by the variable ispell-local-dictionary
or, if that is nil
, by the variable ispell-dictionary
.
If both are nil
, the spelling program’s default dictionary is
used. The command M-x ispell-change-dictionary sets the
standard dictionary for the buffer and then restarts the subprocess,
so that it will use a different standard dictionary. Your personal
dictionary is specified by the variable
ispell-personal-dictionary
. If that is nil
, the
spelling program looks for a personal dictionary in a default
location, which is specific to each spell-checker.
A separate dictionary is used for word completion. The variable
ispell-complete-word-dict
specifies the file name of this
dictionary. The completion dictionary must be different because it
cannot use the information about roots and affixes of the words, which
spell-checking uses to detect variations of words. For some
languages, there is a spell-checking dictionary but no word completion
dictionary.
Flyspell mode is a minor mode that performs automatic spell-checking
of the text you type as you type it. When it finds a word that it
does not recognize, it highlights that word. Type M-x flyspell-mode to toggle Flyspell mode in the current buffer. To
enable Flyspell mode in all text mode buffers, add
flyspell-mode
to text-mode-hook
. See Hooks. Note
that, as Flyspell mode needs to check each word across which you move,
it will slow down cursor motion and scrolling commands. It also
doesn’t automatically check the text you didn’t type or move across;
use flyspell-region
or flyspell-buffer
for that.
When Flyspell mode highlights a word as misspelled, you can click on
it with mouse-2 (flyspell-correct-word
) to display a menu
of possible corrections and actions. If you want this menu on
mouse-3 instead, enable context-menu-mode
. In addition,
C-. or ESC TAB (flyspell-auto-correct-word
)
will propose various successive corrections for the word at point, and
C-c $ (flyspell-correct-word-before-point
) will pop
up a menu of possible corrections. Of course, you can always correct
the misspelled word by editing it manually in any way you like.
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 M-x flyspell-prog-mode to enable or disable this mode in the current
buffer. To enable this mode in all programming mode buffers, add
flyspell-prog-mode
to prog-mode-hook
(see Hooks).