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

How do I navigate between spelling errors and fix them in Vim?

Answer

]s

Explanation

Once spell checking is enabled with :set spell, Vim highlights misspelled words and provides a navigation and correction workflow that keeps your hands on the keyboard.

How it works

  • ]s — jump to the next misspelling after the cursor
  • [s — jump to the previous misspelling
  • z= — show a numbered list of suggested corrections for the word under the cursor; type the number and <CR> to accept
  • zg — mark the word under the cursor as good (adds it to your personal dictionary at ~/.vim/spell/)
  • zw — mark the word under the cursor as wrong (useful for domain-specific jargon you want flagged)
  • zug / zuw — undo a zg or zw decision

Example

Enable spell checking for English and navigate errors:

:set spell spelllang=en_us

With the cursor anywhere in the file:

]s          " jump to first misspelling
z=          " list suggestions (pick with number + Enter)
]s          " continue to next misspelling

Tips

  • Add :set spell to your ~/.vimrc only for specific file types using an autocmd: autocmd FileType markdown,gitcommit setlocal spell
  • 1z= accepts the first (top) suggestion without showing the menu — useful when the first suggestion is obviously correct
  • :set spellcapcheck= disables the check for capitalization at sentence starts if it generates too much noise
  • set spellfile=~/.vim/spell/en.utf-8.add specifies where personal word additions are stored

Next

How do I build a macro programmatically using Vimscript instead of recording it?