In vimscript, when I want to store the return value of a function, I do
let a:foo = Function()
But I now have a ranged function. I would like to store its return value, ideally via something like the following:
let a:foo = l:start,l:end call RangedFunction()
(this does not work, but it illustrates my objective)
Attempts/ideas
- Using
execute
, this calls my function, but does not let me save its return value. There must be a tricky smart way to get this to work, but it feels pretty heavy.
execute a:start.",".a:end." call RangedFunction()"
- I could pass the
range
lines as two explicit arguments directly in the function.
function RangedFunction(start,end)
but then I couldn't call my function using :10,12call RangedFunction()
, which is a flexibility I'd like to keep, and it would make my function implementation heavier.
This is probably a syntax thing I've missed while searching the doc, but it keeps escaping me !
func-range
? vimhelp.org/userfunc.txt.html#%3Afunc-range It would require some changes to the function