vimtricks.wiki Concise Vim tricks, one at a time.

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

  • zg marks a word as good and appends it to the file specified by spellfile (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 .add file and produces an optimized binary .add.spl alongside it
  • On next startup Vim loads the .spl binary 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 :mkspell periodically or whenever your word list grows by hundreds of entries
  • The ! flag (:mkspell!) overwrites an existing .spl file without prompting
  • To start a fresh word list for a different language: :set spelllang=fr then zg to add French words
  • You can also build a spell file from a plain text dictionary: :mkspell ~/.vim/spell/en /usr/share/dict/words

Next

How do I open the directory containing the current file in netrw from within Vim?