I'm trying to define a command that can take a range and pass it to a function. This is what I thought I should have:
function! PrintGivenRange() range
echo "firstline ".a:firstline." lastline ".a:lastline
" Do some more things
endfunction
command! -range PassRange call PrintGivenRange()
However, it doesn't work that way, it seems to only pass the first line.
e.g.
:1,5PassRange "outputs firstline 1 lastline 1
:1,5call PrintGivenRange() "outputs firstline 1 lastline 5
" if you select lines in visual mode, same thing for both
I've read :help command-range
already but still haven't been able to figure this out. Am I supposed to pass the range in the prefix to the call
? How do I fix this?