I wrote a vim function to print the selected lines of text and perform shortcut key mapping. The code is as follows:
function! EchoVisual()
let st= getpos("'<")[1]
let ed= getpos("'>")[1]
execute '!sed -n '.st.','.ed.'p '.expand('%:p')
endfunction
vmap <leader>e :call EchoVisual()<CR>
But during actual execution, every time I press <leader>e
, the EchoVisual function will be executed repeatedly n times. The size of n is the same as the number of rows I selected. What is this? What's the problem? How to solve it?
Now I know
How?