title: passing command-range to a function
body: <p>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:</p>
  
  <pre><code>function! PrintGivenRange() range
      echo "firstline ".a:firstline." lastline ".a:lastline
      " Do some more things
  endfunction
  
  command! -range PassRange call PrintGivenRange()
  </code></pre>
  
  <p>However, it doesn't work that way, it seems to only pass the first line.</p>
  
  <p>e.g. </p>
  
  <pre><code>: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
  </code></pre>
  
  <p>I've read <code>:help command-range</code> already but still haven't been able to figure this out. Am I supposed to pass the range in the prefix to the <code>call</code>? How do I fix this?</p>