vim Configuring Vim Options


Example

There are three kinds of options:

  • boolean options,
  • string options,
  • number options.

To check the value of an option,

  • use :set option? to check the value of an option,
  • use :verbose set option? to also see where it was last set.

Setting boolean options

set booloption      " Set booloption.
set nobooloption    " Unset booloption.

set booloption!     " Toggle booloption.

set booloption&     " Reset booloption to its default value.

Setting string options

set stroption=baz   " baz

set stroption+=buzz " baz,buzz
set stroption^=fizz " fizz,baz,buzz
set stroption-=baz  " fizz,buzz

set stroption=      " Unset stroption.

set stroption&      " Reset stroption to its default value.

Setting number options

set numoption=1     " 1

set numoption+=2    " 1 + 2 == 3
set numoption-=1    " 3 - 1 == 2
set numoption^=8    " 2 * 8 == 16

Using an expression as value

  • using concatenation:

    execute "set stroption=" . my_variable
    
  • using :let:

    let &stroption = my_variable
    

See :help :set and :help :let.