简体   繁体   中英

How do I take input into variable , from leader key, and execute into a command in vim?

The result that I want is to find tags by doing leader key+t+word.

noremap <leader>t :call someFunc(mystring-after-t)<cr>

function getTag(string)

        execute "normal! :tag " . string "\<cr>"

endfunction 

I am not aware whether is a way to tell a mapping to take some user input. But you could achieve this as follows (I took the liberty to simplify the task at hand a bit for my convenience...)

function EchoWord(x)
  redraw
  echom  'I got the input: ' . a:x 
endfunction

noremap <leader>l :call EchoWord(input(""))<cr>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM