How do I fix a misspelled word using Vim's spell checker while staying in insert mode?
Answer
<C-x>s
Explanation
When spell checking is enabled (:set spell), <C-x>s in insert mode opens a popup menu of suggested corrections for the most recently flagged misspelled word — without needing to leave insert mode. This is part of Vim's insert-mode completion system (<C-x>) and is far faster than switching to normal mode to use z=.
How it works
<C-x>— enters insert-mode sub-completion modes— selects the spell completion sub-mode- Vim moves back to the nearest preceding misspelled word and offers a correction menu
- Use
<C-n>/<C-p>to cycle through suggestions;<CR>or any non-menu key to accept
Example
With :set spell active, after typing:
This is an occurance of the bug
Positioning after occurance and pressing <C-x>s pops up:
> occurrence
occurrences
Choosing occurrence replaces the misspelled word in place.
Tips
- Enable spell checking with
:set spell spelllang=en_usin your vimrc - In normal mode, use
z=over a word to see the same suggestion list ]sand[snavigate to the next/previous spelling error in normal modezgadds the word under the cursor to the spellfile (mark as good),zwmarks it as wrong