In this post, I want to talk about how to enable built-in spell check in Nvim.
Enable spell check
First we need to add the spell check languages:
" spell languages set spelllang=en,cjk
In the above config, we set the spell languages to
language is used to prevent the CJK characters from being marked as spell
errors. This is 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.
To enable spell check, just add
set spell in your configuration file. Since I
do not want to use spell check feature all the time, I set up a toggle for this
option in normal and insert mode:
nnoremap <silent> <F11> :set spell!<cr> inoremap <silent> <F11> <C-O>:set spell!<cr>
So we can press F11 to toggle spell checking.
Correcting spell errors in insert or normal mode
In insert mode, if you have type some word which Vim thinks is spelled wrongly,
a curly underline is shown below the word. To correct the error, you can press
s. A completion menu will show a list of suggestions. You
can then choose the correct one.
In normal mode, to navigate between the possible spell errors, use the following shortcut key:
[s: go to previous spell error
]s: go to next spell error
To correct the error, use
z=. A list of candidate words will be shown. You
are prompted to enter a number to select the correct word. Or you can use
to directly choose the first candidate.
License CC BY-NC-ND 4.0