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

How do I add or remove words from Vim's spell check dictionary?

Answer

zg and zw

Explanation

When Vim's spell checker marks a word as incorrect but it is intentionally spelled that way (a name, abbreviation, or domain-specific term), you can permanently add it to your personal dictionary with zg. To mark a word as wrong and add it to your bad-words list, use zw. Both commands update your spellfile on disk so the change persists across sessions.

How it works

  • zg — mark the word under the cursor as good (adds it to ~/.vim/spell/<lang>.utf-8.add)
  • zw — mark the word under the cursor as wrong (adds it to the spellfile as a bad word)
  • zug — undo zg (remove from good-words list)
  • zuw — undo zw (remove from bad-words list)
  • The spellfile path is controlled by :set spellfile; you can version-control it per project

Example

Vim flags: "Kubernetes" as a misspelling
Cursor on "Kubernetes" → press zg
→ Added to spell dictionary
→ Word is no longer highlighted as an error

Press zug to undo if you change your mind

Tips

  • Run :set spell spelllang=en_us first to enable spell checking
  • Use ]s / [s to jump to the next/previous misspelling, then zg to accept it
  • zG and zW do the same as zg/zw but save to an internal word list for the current Vim session only (not written to disk)
  • Share your .add spell file across machines via dotfiles to keep your custom vocabulary in sync

Next

How do I use capture groups in Vim substitutions to rearrange or swap matched text?