0

I defined these maps, to yank into system clipboard.

noremap <leader>y "*y
noremap <leader>Y "*Y
noremap <leader>yy "*yy

But when I use the first one (<leader>y), I find it extremely slow (taking some 4 or 5 seconds, but functioning properly). Why? What are possible reasons? How can I find cause of problem?

  • 3
    In the case of the first one, you've defined y and yy so vim is waiting after the first y to see if you'll type another. I can't speak to the other two though; they should execute immediately unless you have more leader mappings that start with those characters. – Tumbler41 Jun 29 '17 at 14:15
  • You could find the 'clipboard' option useful – mMontu Jun 29 '17 at 15:59
  • @Tumbler41 Sorry, I find only <leader>y is slow. My memory is unreliable. Just as you said, you are correct. – Violapterin Jun 29 '17 at 16:03
1

When you define a multi key mapping that starts with character that is itself a mapping, vim doesn't know which one you want after only the first character. It waits to see if you'll type another character indicating the longer mapping. If you don't type anything, after some time it will use the shorter mapping.

You can change the amount of time it waits by changing the the ttimeoutlen setting. It's given in milliseconds.

For more info see :help 'ttimeoutlen'.

0

(Posting this as an answer to make it more visible) The <nowait> does not work, and I don't want to shorten the timeoutlen. So, I redefined key bindings to rid the ambiguity. Now all commands are lightning fast.

nmap <leader>y "*y
vnoremap <leader>y "*y
nnoremap <leader>Y "*y$
nnoremap <leader>yy "*yy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.