Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display value of :set option

Tags:

vim

option

If you don't give :colorscheme an argument then it shows the name of the colorscheme that vim is currently using. Is there a similar way in vim to show if an option is set or what the value of the option is set to if it isn't a boolean? For example, if I wanted to know whether autoindent is set or I wanted to know the value of textwidth, how would I find that?

like image 338
Kristian Avatar asked Aug 21 '12 18:08

Kristian


2 Answers

Use the :set command.

  • :set autoindent? prints the option, and its value, if any. Vim toggle options (booleans, options that are on/off), like autoindent, are prefixed with no to indicate that they're turned off, so :set autoindent? will display autoindent or noautoindent.
  • :set autoindent turns autoindent on.
    • this form turns toggle options on
    • for number or string options, this shows the value of the option, so :set textwidth will also print the value of the option. For number or string options, :set option is equivalent to :set option?.
  • :set autoindent! inverts the option. autoindent becomes noautoindent.
  • :set autoindent& reverts autoindent to its default value.
  • Set number or string options with :set option=value, e.g. set tabstop=3
like image 133
pb2q Avatar answered Oct 18 '22 03:10

pb2q


Use :set textwidth? to show the value of textwidth.

Use :verbose set textwidth? to show where this value was last set.

In general, you can add ? after the setting name to show its current value.

like image 26
K Z Avatar answered Oct 18 '22 04:10

K Z