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

How do I temporarily set a Vim option?

Answer

:set option

Explanation

The :set command changes Vim options for the current session. Options can be boolean (on/off), numeric, or string values.

How it works

  • :set number enables line numbers
  • :set nonumber disables line numbers
  • :set number! toggles line numbers
  • :set number? queries the current value

Example

:set number           " Enable line numbers
:set tabstop=4        " Set tab width to 4
:set wrap!            " Toggle line wrapping
:set filetype?        " Show current filetype

Tips

  • :setlocal sets the option only for the current buffer/window
  • :set all shows all option values
  • :set option& resets an option to its default
  • Add options to your vimrc for permanent settings
  • Use Tab completion after :set for option names

Next

How do you yank a single word into a named register?