I've created a mapping to a function that accepts a range. Like this:
command! -range Test call TestFunc(<range>,<line1>,<line2>)
nnoremap <leader>t :Test<CR>
How do I supply a specific range to the mapped command, in normal mode?
For example: from current line to line 81, apply mapped command t
. Something like .,81\t
.
How can the same thing be done using marks?
The function, by the way, is written thus:
function! TestFunc(r,l1,l2) abort
if a:r == 0
echo "No range"
elseif a:r == 1
echo "Single Line given (like :22Test)"
else
echo "Line range given (like :1,23Test, '<,'>Test or %Test)"
endif
endfunction
It simply says what sort of range it got. (I don't remember what the abort statement was in aid of).
When I have actually applied this to functions, I've required it to work both with and without ranges.
:nnoremap <leader>t :Test<C-b>
; then you can type the range and press enter.\t.,81<cr>
, since<C-b>
puts your cursor between:
andTest
.