选项

有三种选择:

  • 布尔选项,
  • 字符串选项,
  • 数字选项。

要检查选项的值,

  • 使用:set option? 来检查选项的值,
  • 使用:verbose set option? 也可以看到它最后设置的位置。

设置布尔选项

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

set booloption!     " Toggle booloption.

set booloption&     " Reset booloption to its default value.

设置字符串选项

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.

设置数字选项

set numoption=1     " 1

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

使用表达式作为值

  • 使用连接:

    execute "set stroption=" . my_variable
    
  • 使用:let

    let &stroption = my_variable
    

:help :set:help :let