Vim spellfile

Vim can maintain a spellfile that contains “good words” that are not in the dictionary used by Vim.

Location

By default, the spellfile is in ~/.vim/spell. Vim keeps two files with names that formatted as lang.encoding.add and lang.encoding.add.spl. For example, en.utf-8.add and en.utf-8.add.spl. The file ending in .add is in plain text format and can be backed up to version control, copied to different computers, edited manually, etc. However, the binary file ending in .spl is required for Vim to use the spellfile. Vim automatically builds the binary file when you add a word to the dictionary. However, if you’ve duplicated an existing plain text file, you must manually generate the binary file with the mkspell command.

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

Usage

As always, view the full documentation by running the help command.

:help spell

Common commands

Buffer commands

  • zg - Add word under cursor as a good word to spellfile
  • zw - Add word under cursor as a wrong word to spellfile
  • zug - Undo zg, remove the word entry from spellfile
  • zuw - Undo zw, remove the word entry from spellfile

Command-line commands

  • :spe[llgood] {word} - Add {word} as a good word to spellfile
  • :spellw[rong] {word} - Add {word} as a wrong word to spellfile
  • :spellu[ndo] {word} - Undo, remove the word entry from spellfile
  • :runtime spell/cleanadd.vim - Clean up comment lines in all spell files