vimtricks.wiki Concise Vim tricks, one at a time.

How do I enable spell checking in Vim?

Answer

:set spell

Explanation

The :set spell command activates Vim's built-in spell checker, which highlights misspelled words directly in your buffer. This is invaluable when writing documentation, commit messages, comments, or any prose within Vim.

How it works

  • :set spell enables spell checking for the current buffer
  • Misspelled words are highlighted (typically with a red underline or wavy line, depending on your color scheme)
  • By default, Vim uses the English language dictionary

Navigating misspelled words

  • ]s — jump to the next misspelled word
  • [s — jump to the previous misspelled word
  • z= — show a list of spelling suggestions for the word under the cursor
  • zg — add the word under the cursor to your personal dictionary (mark it as "good")
  • zw — mark the word under the cursor as misspelled (undo zg)
  • 1z= — automatically accept the first spelling suggestion

Example

You are writing a README file and type:

This is a tstrng with som misspeled words.

After running :set spell, Vim highlights tstrng, som, and misspeled. Press ]s to jump to tstrng, then press z= to see suggestions like testing, tasting, string. Select the correct one by typing its number.

Changing the spell language

To check spelling in a different language or multiple languages:

:set spelllang=en_us
:set spelllang=en_us,de

Tips

  • Use :set nospell to turn off spell checking
  • Use :setlocal spell to enable spell checking only in the current buffer
  • Use zg liberally to teach Vim about technical terms, project-specific words, and proper nouns so they stop being flagged
  • Add spell checking to specific file types in your vimrc:
autocmd FileType markdown,text,gitcommit setlocal spell
  • Use :set spellfile=~/.vim/spell/custom.utf-8.add to specify a custom dictionary file for your added words
  • Vim can download spell files automatically — if you set a language that is not installed, Vim will offer to download it for you

Next

How do I edit multiple lines at once using multiple cursors in Vim?