How do I compile a custom word list into a Vim spell file for faster spell checking?
Answer
:mkspell ~/.vim/spell/en.utf-8.add
Explanation
When you add words to your personal spell file with zg, Vim writes them to a plain-text .add file. Over time, Vim rescans this file on every startup. Running :mkspell compiles it into a binary .spl file that Vim loads instantly, which matters when your custom word list grows large.
How it works
zgmarks a word as good and appends it to the file specified byspellfile(typically~/.vim/spell/en.utf-8.add)- Vim loads and parses this text file every time it starts — fine for small lists, slow for large ones
:mkspell {spellfile}reads the.addfile and produces an optimized binary.add.splalongside it- On next startup Vim loads the
.splbinary instead, skipping the parse step
Example
After adding many custom words with zg, rebuild the compiled spell file:
:mkspell ~/.vim/spell/en.utf-8.add
Or use the shorthand to recompile all loaded spell files for the current buffer:
:mkspell! %
Vim confirms: Word list information written to: ~/.vim/spell/en.utf-8.add.spl
Tips
- Run
:mkspellperiodically or whenever your word list grows by hundreds of entries - The
!flag (:mkspell!) overwrites an existing.splfile without prompting - To start a fresh word list for a different language:
:set spelllang=frthenzgto add French words - You can also build a spell file from a plain text dictionary:
:mkspell ~/.vim/spell/en /usr/share/dict/words