A short primer on spell check in vim

23. November 2020
vim knowledge howto

(Neo)Vim provides a built-in spell checking engine. As vim is the only text editor you will ever need again this is quite a handy feature, for example for writing mail, notes and TeX-documents.

Setup

So, now for the setup: Open your init.vim and add:

set spell

And that's it. Mostly. You can change the language by spelllang, so change the above for example to:

set spell
set spelllang=de

When setting this for the first time, neovim will ask you if it should download the appropriate dictionary file. Confirm this, and you will be able to use it. You can also use the short form spl instead of spelllang.

When setting this in the main init.vim spell check will be enabled for all file types, which is probably not what you want. Instead, set this only in the file type specific setting files, for which you want spell check enabled. See my dotfiles for reference, for example take a look at the markdown filetype settings.

Usage

Vim will mark wrongly spelled words. You can navigate to the next wrong word with ] s and the previous wrong word with [ s . When your cursor is on a wrong word, you can display the suggestions with z = , select the correct version and hit enter. If you are pretty sure, that the first entry in the list is what you want you can shorten this process by using 1 z = , this will choose the first entry, but you can change 1 to any other number, to choose the nth entry.

The provided word list will probably be not sufficient, as there might be names and abbreviations you use, that are not in the list. To mark a wrongly marked word as ‘correct’, set your cursor on it and hit z g , this will add the word to the ‘good’ list. There is also a list for bad words, which works by using z b .

There are some more clever settings and features, be sure to take a look at the documentation under :help spell.