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
&optionvariable. For example:See
:help let-&. The&l:is listed a little below that tag showing that it is for the equivalent ofsetlocal. Basically, when you want to set an option to an expression instead of a defined value then you need to uselet &option=instead ofset option=. Uselet &l:option=instead ofsetlocal option=. There is also&g:optionto set the option globally.