Skip to main content
  1. Posts/

Spell Checking in Nvim

··309 words·2 mins·
Table of Contents
Update log
  • 2021-10-17: add spellsuggest option.

In this post, I want to talk about how to enable the built-in spell checking feature in Nvim.

Enable spell check

First we need to add spell checking languages:

" spell languages
set spelllang=en,cjk

In the above config, we set spell languages to en and cjk. Item cjk is used to prevent CJK characters from being marked as spell errors. This is also documented in the Nvim doc:

If the name “cjk” is included, East Asian characters are excluded from spell checking. This is useful when editing text that also has Asian words.

Another option to tweak is spellsuggest, I use the following settings:

" Show nine spell checking candidates at most
set spellsuggest=best,9

To enable spell checking, run command :set spell. I have set up two mappings to toggle spell checking:

nnoremap <silent> <F11> :set spell!<cr>
inoremap <silent> <F11> <C-O>:set spell!<cr>

We can then press F11 to toggle spell checking.

Correct spell errors

In insert mode, if you have typed a word which Vim thinks is miss-spelled, an underline is shown below. To correct this error, press <C-x> followed by s. A completion menu will show a list of suggestions. You can then choose the correct one.

In normal mode, to navigate between possible spell errors, use the following shortcut:

  • [s: go to previous spell error
  • ]s: go to next spell error

The built-in spell checker is not perfect and can create false positives easily. If you think a word is not a spell error, you can use zg to add it to your spell file. To correct an error, press z=. A list of candidate words will be shown. You are prompted to enter a number to select the correct one. Or you may use 1z= to choose the first candidate directly.



Sort lines based on a column in Vim/Nvim
··231 words·2 mins
A Beginner's Guide on Creating Your Own Text Objects from Scratch in Neovim/Vim
··1234 words·6 mins
How to Insert Unicode Characters in Neovim/Vim
··697 words·4 mins