How to set numeric variables in vim functions
vim
Solution
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.
Problem
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?