Home  >  Q&A  >  body text

When mapping is executed multiple times in vim selection mode

function Hello()
        echo "hello world\n"
endfunction

map <leader>w :call Hello()<CR>

In normal mode, I press <leader>w to call the Hello() function once, but if I am in the selection mode, the Hello() function will be called n times, the number of n times and the selection The number of rows is the same. If I now want to call the function only once in selection mode, how should I deal with it?

漂亮男人漂亮男人2712 days ago692

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-05-16 16:43:58

    Processing range by yourself:

    function Hello() range
    

    See also:

    :help :call
    

    reply
    0
  • Cancelreply