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 misspellingz=— show a numbered list of suggested corrections for the word under the cursor; type the number and<CR>to acceptzg— 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 azgorzwdecision
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 spellto your~/.vimrconly 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 noiseset spellfile=~/.vim/spell/en.utf-8.addspecifies where personal word additions are stored