Spell Checking in Vim: A Comprehensive Guide
Table of Contents ๐
Spell checking is an essential feature for any editor, and Vim comes with a powerful built-in solution. This guide will walk you through everything you needโfrom basic activation to advanced customization and keyboard-layout considerations.
Changelog
Date | Change |
---|---|
2025-06-25 | Added QWERTZ key mappings and .sug file clarification. |
2025-06-25 | Initial version of the guide. |
Enabling Spell Checking
To enable Vimโs spell checker, use the :set spell
command. You can type this directly into Vim for the current session, or add it to your ~/.vimrc
file for permanent activation.
:set spell " Turn on spell checking
:set spelllang=en_us " Set the default language (e.g., US English)
The first time you set a language, Vim may offer to download the dictionary file for you. This is a one-time setup for each language.
For German, switch to:
:set spelllang=de_de " Set German dictionary
You can list multiple languages, and Vim will check against all of them:
:set spelllang=de_de,en_us
Pro-tip: Vim supports regional variants like en_gb
(British), en_ca
(Canadian), and en_au
(Australian).
Managing Spell Files
Vim uses two main types of files for spell checking:
- The main dictionary (
.spl
file), a compressed word list used for all checks. - A supplementary suggestions file (
.sug
file), which pre-computes lists of similar words to provide fast suggestions.
Benefits and Trade-offs of the .sug
file
- With
.sug
downloaded:z=
suggestion requests are fast and comprehensive, as Vim doesnโt need to calculate similarities on the fly. - Without
.sug
: Vim computes suggestions at runtime, saving disk space and RAM until a suggestion is needed.
On-Demand Loading
Vim only loads the .sug
file into memory when you invoke suggestions (e.g., by pressing z=
). Simply enabling spell check and navigating errors with ]s
/[s
wonโt load the larger .sug
file, keeping your memory footprint minimal until you request corrections.
Quick Navigation and Corrections
]s
: Jump to the next misspelled word[s
: Jump to the previous misspelled wordz=
: On a highlighted word, opens the suggestion listzg
: Add word to good list (your personal dictionary)zw
: Mark word as wrong
" Example vimrc settings:
set spell
set spelllang=de_de,en_us
" Optional: Define a custom file for your personal dictionary
set spellfile=~/.vim/spell/en.utf-8.add
Keyboard Layouts and Key Mappings
Vimโs navigation commands rely on specific characters (]
, [
, s
), not on physical keys. Below we cover the standard QWERTY layout and the German QWERTZ variant.
International QWERTY (Default Mapping)
- Press
]
thens
to go to the next misspelling. - Press
[
thens
to go to the previous misspelling.
No special configuration is needed on US/UK keyboards, where [
and ]
are directly accessible.
German QWERTZ Layout
On German keyboards, the square brackets require AltGr
:
[
:AltGr + 8
]
:AltGr + 9
Thus, to navigate spelling corrections:
AltGr + 9
, thens
โ]s
(next error)AltGr + 8
, thens
โ[s
(previous error)
๐ก QUICK KEY MAPPINGS ON QWERTZ |
To simplify this, add these mappings to your We use |
Conclusion
Vimโs spell checker is both versatile and efficient. By understanding its core commands and how to adapt them to your keyboard layout, you can keep your writing error-free across multiple languages. Incorporate these settings into your Vim configuration for a seamless workflow.
โน๏ธ KEY COMMANDS AT A GLANCE |
|
For a deeper dive into all available options, the official documentation is an excellent resource.
๐