Repeat the mapping command in vim view mode
PHP中文网
PHP中文网 2017-05-16 16:42:01
0
2
728

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?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
漂亮男人

Now I know

command! -range=% EchoVisual :!sed -n <line1>,<line2>p %:p
vmap <leader>e :EchoVisual<CR>
阿神
command! -range=% EchoVisual :<line1>,<line2>p | echo expand('%:p')
vmap <leader>e :EchoVisual<CR>

How?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template