WARNING! This article has been written a long time ago. It may no longer represent the current views of the author!

Using Vim's built-in spellchecker

Recently, I have took some time to evaluate my workflow when using Vim and I started to wonder if I really need to use the aspell command for checking the spelling of the article?

The answer is - of course not!

Vim - being the awesome editor it is - has a built-in spellchecker. I have just never reflected on the idea of using the editor itself for the task. I think that my error can be more widespread, so here is the quick guide for enabling the spellchecker.

First of all, I recommend looking at the documentation:

:help spell

(First thing to note is that this is strictly a Vim feature - sorry, Vi users). But if you are lazy (or don't want to look at the docs) here is the basic modus operandi.

What to do

  1. Enable spell
    :setlocal spell 
  1. Set the language that the text is written in
    :setlocal spellang=en

And that's it - now using the command ]s and [s you can jump between the words with bad spelling. If you wish to get advice on the spelling - having cursor on the word press z= to get a list of possible spellings.

This isn't perfect, we can do better, of course. We can setup Vim to visually show us where the badly spelled words are - like this:

:highlight SpellBad cterm=underline ctermfg=red

And now the wrong words will be colored red and underlined. (Side note: when using GVim you can set the cterm to undercurl to achieve an effect similar to most word processors).

I hope this was somewhat interesting and useful to read. There are more the this 'subsystem' in Vim - I strongly recommend digging through the documentation.