How do I configure a custom word list file for Vim spell checking so I can persist accepted words?
Answer
:set spellfile={path}
Explanation
By default, when you use zg to add a word to Vim's spell-check dictionary, it is saved in a file in your Vim data directory. The 'spellfile' option lets you point that file at a location you control—such as a path inside your dotfiles repository—so that your personal dictionary is portable and version-controllable.
How it works
:set spellfile=~/.config/nvim/spell/en.utf-8.add— words added withzgare written here- Multiple files can be specified as a comma-separated list;
zgalways writes to the first one - The file is a plain-text list that Vim automatically compiles to a
.splbinary on load - Combine with
:set spell spelllang=en_usto activate spell checking
Example
Add to your vimrc or init.lua:
set spell spelllang=en_us
set spellfile=~/.config/nvim/spell/en.utf-8.add
Now every word you accept with zg is written to that file. Commit the file to your dotfiles repo and your custom dictionary follows you everywhere.
Tips
- Use
zgto mark a word as good,zwto mark it as wrong, andzugto undo an addition - If the compiled
.splfile is missing or stale, Vim will regenerate it automatically - You can ship a pre-filled wordlist in a plugin or dotfiles repo and point
spellfileat it