The default VIM7 install is equipped with the English dictionary, but as I’m Dutch I wanted to use the Dutch spelling, unfortunately these spell files are not included in Ubuntu. The following article is a short howto on how to add this wonderful feature to your VIM.

Dutch spelling

Download your language from the debian experimental archive.

I needed Dutch so I downloaded:

/main/v/vim-spellfiles/vim-spellfiles-nl_20060604-1_all.deb

Install this with:

dpkg -i vim-spellfiles-nl_20060604-1_all.deb

This will put some files in /usr/share/vim/addons. By default VIM will not look in that directory. To fix this I’m creating some symlinks from my local .vim directory:

cd ~/.vim/spell
ln -s /usr/share/vim/addons/spell/* .

Now VIM should be able to find your spell files.

.vimrc

Add the following to your .vimrc file:

setlocal spell spelllang=en
set spellfile=~/.vim/spellfile.{encoding}.add

With this you enable spell checking for the English language.

key mapping

I’ve added some key mappings to enable Dutch or English checking or to disable it entirely. I’m using control-E for English, control-N for Dutch (nederlands) and control-O for off.

map     <C-E>    :setlocal spell spelllang=en_us<CR>
imap    <C-E>    <ESC>:setlocal spell spelllang=en_us<CR>i
map     <C-O>    :setlocal spell spelllang=<CR>
imap    <C-O>    <ESC>:setlocal spell spelllang=<CR>i
map     <C-N>    :setlocal spell spelllang=nl<CR>
imap    <C-N>    <ESC>:setlocal spell spelllang=nl<CR>i

autocmd For some filetypes want to use a different language, so I also have these:

autocmd Filetype c setlocal spell spelllang=en
autocmd Filetype perl setlocal spell spelllang=en
autocmd Filetype mail setlocal spell spelllang=nl

So my default settings when I’m emailing is to use the Dutch language.

Highlighting

The default highlighting seems to suck, but this guy had a fix. Add the following to your color file are to you .vimrc:

:highlight clear SpellBad
:highlight SpellBad term=standout ctermfg=1 term=underline cterm=underline
:highlight clear SpellCap
:highlight SpellCap term=underline cterm=underline
:highlight clear SpellRare
:highlight SpellRare term=underline cterm=underline
:highlight clear SpellLocal
:highlight SpellLocal term=underline cterm=underline

This gives you some nice underlining, not to fancy, but just enough to make you notice :).

Using it

The following key are important when using VIM spelling:

  • z= when a word is spelled incorrectly get a listing of alternatives
  • zG add the word to the spelling file, it is a Good word.
  • zW mark the word as bad in the spelling file.

Happy VIM-ing