I often call
:set spell
only to immediately call
:set nospell
once I've corrected the word I was unsure of.
I can make this faster by mapping both commands, but I'm looking for a more general way to speed this up. Is it possible to undo the last option :set?
Strictly speaking, no, you cannot undo setting a setting in Vim.
But boolean options like 'spell'
can be toggled with either one of
:set spell!
:set invspell
In interactive use there is generally no need to specifically :set spell
or :set nospell
. Toggling is more convenient and can be immediately "undone" with the @:
command.
Non-boolean options can be undone by resetting them to their factory values – say, if you have messed up some setting and wish to revert. Example:
:set formatoptions&
A &
appended to the option name resets it to its default value.
The solution explained in this answer is also documented in vim-help, in case you forget and need to find it again in the future:
:help set-default