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

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 mode
  • s — 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_us in your vimrc
  • In normal mode, use z= over a word to see the same suggestion list
  • ]s and [s navigate to the next/previous spelling error in normal mode
  • zg adds the word under the cursor to the spellfile (mark as good), zw marks it as wrong

Next

How do I run text I've yanked or typed as a Vim macro without recording it first?