I'm trying to write a function that calls setlocal
to set some variables to the param(s) that I pass in. But I'm getting the error Number required after =: tabstop=...
function! MyFunction(param)
setlocal tabstop=param
setlocal tabstop=a:param
endfunction
Both lines will fail. Is there some sort of variable interpolation I'm missing?
You need to define the option as an &option
variable. For example:
fun! MyFun(param)
let &l:tabstop = a:param
endfun
See :help let-&
. The &l:
is listed a little below that tag showing that it is for the equivalent of setlocal
. Basically, when you want to set an option to an expression instead of a defined value then you need to use let &option=
instead of set option=
. Use let &l:option=
instead of setlocal option=
. There is also &g:option
to set the option globally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With