I have a function somewhat like this:function! MyFunction()    g/\v.(\n\n|\n*%$)/execute normal! v{:call AnotherFunction()\<cr>endfunctionNow I want to be able to pass a range to that function. The problem is how can I add the range (a:firstline and a:lastline) before the g command? I tried all the combinations I could think of (like execute a:firstline.','.a:lastline' 'g/...), but I can't get it to work (maybe because I already use execute in the global command).
Run global with range from within function
vimscript;global command
From the documentation (:h function-range-example):function Cont() range  execute (a:firstline + 1) . , . a:lastline . 's/^/\t\\ 'endfunction4,8call Cont()You need to use execute to pass the variables to the g command.In your case, this simplified example should work (at least it works here):function! MyFunction()    execute a:firstline . ',' . a:lastline . 'g/^/execute normal! >>'endfunction1,3call MyFunction()