For example, I'd like to set
set tabstop=4
set shiftwidth=4
Is there a way to do something like
set tabstop=4
set shiftwidth=tabstop
so I can set both values by only changing a single number?
For example, I'd like to set
set tabstop=4
set shiftwidth=4
Is there a way to do something like
set tabstop=4
set shiftwidth=tabstop
so I can set both values by only changing a single number?
You can use the let command instead.
Like so:
let &shiftwidth = &tabstop
The & specifies that the variable name is a Vim option. You can also do :help let-option to know more about it:
:let &{option-name} = {expr1}
Set option {option-name} to the result of the
expression {expr1}. A String or Number value is
always converted to the type of the option.
For an option local to a window or buffer the effect
is just like using the |:set| command: both the local
value and the global value are changed.
Might be a better way but you could always do this:
exec 'set shiftwidth=' . &tabstop
Specifically in this case:
http://vimhelp.appspot.com/options.txt.html#%27softtabstop%27:
When 'sts' is negative, the value of 'shiftwidth' is used.
http://vimhelp.appspot.com/options.txt.html#%27shiftwidth%27
When ['shiftwidth' is] zero the 'ts' value will be used.
&l:shiftwidthto only change the buffer local variable. – jamessan Mar 03 '15 at 15:26