Spelling in Vim

Since version 7.0 Vim includes a spelling corrector without the need of installing any plugins. The usage is pretty simple once you have configured some shortcuts in your vimrc, for example I have:

nmap  :setlocal spell spelllang=en_en<cr>
nmap  :setlocal spell spelllang=es_es<cr>

This makes the spelling correction to start when I press Control+s (for Spanish) or Control+g (for English). If this is the first time you enable spelling for some language, it will download a dictionary.

If we use gVim, the spelling marks errors with a little curved underline like word processors (in text mode it will change the background color of the mispelled words). Also like in word processors, the spelling works in real time once enabled.

Some common spelling commands:

  • zg: add the word under the cursor to the dictionary
  • [s y ]s: move to next/previous spelling error
  • z= : show spelling suggestions for the word under the cursor

We can see all the commands with “:help spell”. To disable spelling we write “:set nospell”.

tags: [ articles · software libre · linux · programacion · vim ]
comments powered by Disqus