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

DateChange
2025-06-25Added QWERTZ key mappings and .sug file clarification.
2025-06-25Initial 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 word
  • z= : On a highlighted word, opens the suggestion list
  • zg : 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 ] then s to go to the next misspelling.
  • Press [ then s 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, then s โ†’ ]s (next error)
  • AltGr + 8, then s โ†’ [s (previous error)
๐Ÿ’ก QUICK KEY MAPPINGS ON QWERTZ

To simplify this, add these mappings to your ~/.vimrc:

" F7: Next misspelling
nnoremap <F7> ]s
" F6: Previous misspelling
nnoremap <F6> [s

We use nnoremap to create a non-recursive mapping in Normal mode, which is the safest way to define custom shortcuts. Now a single press of F7 or F6 navigates errors without needing AltGr.

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
  • Navigate Errors: ]s (next) and [s (previous)
  • Get Suggestions: z=
  • Add to Dictionary: zg (โ€œgoodโ€ word)
  • Mark as Wrong: zw (โ€œwrongโ€ word)

For a deeper dive into all available options, the official documentation is an excellent resource.

๐Ÿ“–READ THE OFFICIAL DOCS