I'm trying to write a function + map that works on a visual selection. My function just prints out the marks right now:
let g:count = 0
function! s:plink(...) abort
let g:count = g:count + 1
echomsg printf("%d %s %d %s %d", g:count, a:1, line(a:1), a:2, line(a:2))
endfunction
vnoremap <Leader>r :call <SID>plink("'<", "'>")<CR>
I was surprised to find out that my function is being called once per line when I invoke it as shift-V
, select lines, \r
:
1 '< 80 '> 84
2 '< 80 '> 84
3 '< 80 '> 84
4 '< 80 '> 84
5 '< 80 '> 84
How do I make this snippet call my code only once when I invoke it?