Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to make spellfile in Vim

📅 2015-Sep-30 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ spellcheck, spellfile, vim ⬩ 📚 Archive

Vim can be used to perform a spellcheck of your document, as described here. Vim can maintain a spellfile for you where you can add your good words that are not in the dictionary used by Vim for spellcheck.

This spellfile by default is stored in the directory ~/.vim/spell and its filename is of the format lang.encoding.add. lang is what you set in the spelllang variable. encoding is what you set in the encoding variable. For example, on my system this file is named en.utf-8.add.

The spellfile described above is in plaintext format and has one word per line. You can back it up to version control, copy it to different computers and edit it yourself to add or remove words.

However, to actually use the spellfile for spellcheck, Vim needs to convert this to an optimal lookup data structure and store it as a binary file in the same directory with a .spl suffix. For example, on my system this is the file: ~/.vim/spell/en.utf-8.add.spl. The extremely confusing fact is that Vim refers to both types of these files as spellfile in its documentation!

Vim automatically builds the binary spellfile when you add a word to the dictionary. However, if you had copied the text spellfile from another computer, you may need to manually generate the binary spellfile once.

To make the .spl binary spellfile from the .add text spellfile, use the mkspell command:

:mkspell! ~/.vim/spell/en.utf-8.add

Tried with: Vim 7.4 and Ubuntu 14.04