Emacs Advent Calendar 12: Spell checking
In addition to providing commands for fixing typos, Emacs can also do spell checking on buffer contents.
To check a single word, press
M-$. To check the spelling of
the whole buffer, use
M-x ispell. If active, both commands
will operate on a region instead.
For every word that is not in the dictionary, Emacs will ask you what to do. Normally it will present a list of similar words from which one can be chosen with the associated key. Other actions are summarized in the following table.
|r||replace with new word|
|R||replace with new word and do a query-replace|
|a||accept as correct for this session|
|i||insert word into private dictionary|
|u||insert lower case word into private dictionary|
|X, C-g||suspend interactive spell checking|
|x||quit spell checking|
Note that a suspended spell checking session can be resumed from the
location where point was left on suspension by pressing
M-$. In contrast, quitting a session will move point back to
where interactive spell checking started.
To set the dictionary used for spell checking, run
ispell-change-dictionary. Use tab-completion to list available
languages. To permanently set the default dictionary, for example to
(setq ispell-dictionary "de_DE") to your
Another useful feature is flyspell mode, which provides, as one might
expect from its name, on the fly spell checking. It can be started
M-x flyspell-mode. A very similar mode is flyspell prog
mode which only checks the spelling of comments and strings.
To permanently activate spell checking for a mode, add flyspell-mode
to the mode's hook in your emacs initialization file, e.g.
This text by Ludger Sandig is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.