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

How do I reset a Vim option back to its compiled default value?

Answer

:set {option}&

Explanation

Append & to any :set command to reset that option to its compiled-in default value — the value Vim shipped with before any vimrc or plugin changed it. This is invaluable when debugging configuration issues or experimenting with settings.

How it works

  • :set — the standard option-setting command
  • {option} — the name of the option to reset (e.g., tabstop, textwidth, wrap)
  • & — the reset suffix; tells Vim to restore the default

Example

:set tabstop=2   " change tabstop
:set tabstop?    " shows: tabstop=2
:set tabstop&    " reset to default
:set tabstop?    " shows: tabstop=8  (Vim's default)

You can reset multiple options in a single command:

:set tabstop& shiftwidth& expandtab&

Tips

  • :set all& resets every option to its compiled default — use carefully as it wipes all customizations
  • :setlocal {option}& resets only the buffer-local copy, restoring the global value instead of the compiled default
  • Pair with :set {option}? before and after to verify what changed
  • This is different from :set {option}= (which sets the option to an empty string), and from default values defined in :help option-default

Next

How do I create a Vim mapping where the keys it produces are computed dynamically at runtime?