How do I accept a flagged word as correct for the current session without permanently adding it to my spellfile?
Answer
zG
Explanation
zG marks the word under the cursor as correctly spelled in Vim's internal word list, which exists only for the current session. When you close Vim, the word is forgotten. This is the temporary counterpart to zg, which permanently adds a word to your spellfile on disk.
How it works
| Command | Effect | Persistent? |
|---|---|---|
zg |
Add word as good to your spellfile | Yes |
zG |
Add word as good to the session-only internal list | No |
zw |
Mark word as bad in your spellfile | Yes |
zW |
Mark word as bad in the internal list | No |
Example
You open a log file full of hostnames or UUIDs that Vim flags as misspelled. Rather than polluting your permanent spellfile with these one-off strings, move the cursor to each flagged word and press zG. The spell highlight disappears for the rest of the session without touching your ~/.vim/spell/ files.
Tips
- To undo a
zGmark, usezuG— theuprefix undoes the marking from the internal list - Pair with
:set spellfileto manage multiple persistent word lists for different languages or projects - Use
zginstead when the word is a genuine addition you want to keep (e.g., your own name, company-specific terminology)