-1

For a special application I am invoking vim with following mapping:

vim -u /root/.vimrc ... -c "nnoremap _z \"zyyq:"

If I map to another key sequence, e.g. <F5>, all works fine.

But with key sequence "_z" I have the poroblem:

I cannot type in that key sequence.

Since the first character "_" is held in the input buffer (and so shown in the bottom line) only for a small fraction of a second.

So I cannot timely type the second character.

If I happen to type the second chararacter quick enough all works well.

Why does vim have this odd feature and how can I supress it.

Regards

1
  • 2
    I noticed that none of the 15 questions you asked have accepted answer although most are answered. May could you accept the ones that solve your problem by using the v button next to the arrow voting buttons. It allow the question to rest :-) Commented Mar 26, 2023 at 6:05

2 Answers 2

3

Here is some background to Vivian's answer.

If Vim only had single-letter commands, handling the "input buffer" you mention, in reality it's more like a queue, would be pretty easy:

  1. key is pressed,
  2. action associated with key is executed,
  3. repeat.

But Vim happens to have multi-letter commands, and also counts and motions, so handling that queue is not that simple in reality:

  1. key is pressed,
  2. another key is waited for disambiguating the first one,
  3. if first key is disambiguated, then associated action is executed,
  4. if not, another key is waited for,
  5. etc.
  6. if first key is not ambiguous anymore, associated action is executed,
  7. repeat.

Moreover, Vim allows you to create custom mappings, like your:

nnoremap _z "zyyq:

that may conflict with built-in commands, which is the case, here, with :help _.

So, when you press _, Vim is incapable of knowing that you want your _z and not the built-in _ without waiting for you to press another key. If you press z, then you get your mapping. If you press any other key, then you get the original _.

In normal conditions, the default timeout should be imperceptible when doing _Z, or any other _<key> combination, because you break out of the timeout. But of course, you may be typing too slowly, or your terminal may be too slow, or your network may introduce too much latency. In those cases, Vim lets you decide how it should handle the problem with four options:

:help 'timeout'
:help 'timeoutlen'
:help 'ttimeout'
:help 'ttimeoutlen'

as in Vivian's answer.

1

You can control this time using the following two parameters:

" Set the timeout to 2 seconds
:set timeoutlen=2000
" Disable the timeout (i.e: set the timeout to infinity)
:set notimeout

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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