1

According to: this wiki &

:help timeout

in vim when I set this option:

 set notimeout ttimeout ttimeoutlen=200

It should set a keycode timeout in 200ms when I add this in my .vimrc file But the problem is it doesn't work for me anyway (it doesn't set keycode timeout). So is it working right? Or I can't feel it? Please let me know why it happens and how can I fix that.

OS: Fedora 26
Terminal: Gnome-terminal 3.24.2 Using VTE version 0.48.4 +GNUTLS
Vim version: VIM - Vi IMproved 8.0
  • Hi there, please provide type and version of OS, terminal and vi/vi clone used. Please provide the result with vim -u NONE – mike Nov 13 '17 at 19:20
  • I tried to enter that option in <vim -u NONE> but it seems it doesn't work or maybe my definition of timeout is different. You know I think when I add that option, vim should give a timeout for those keycodes that made of two characters (for example when I want to delete a whole line with dd I should enter them continuous thus when I enter them separately (with a delay) vim shouldn't delete that line)). Is it true? – Cy8099 Nov 13 '17 at 19:41
0

You're mistaken about what the documentation is referring to when it mentions key codes.

dd is not a key code. It is a just a vim command comprised of two key strokes.

An example of a key code would be ^[[D (alternatively notated as as <Esc>[D), which is what the terminal sends when you press the Left arrow.

The key code timeout is intended to allow Vim to handle such sequences differently when they are typed in (which occurs more slowly than when the terminal sends them), allowing you to, for example, type Esc[D to leave insert mode and then display macro definitions of the macro under the cursor, but also to press the left arrow to move one character to the left in insert mode, even though those two operations result in the same sequence of characters being passed from the terminal to Vim.

As dd is a built-in command, it never times out. However, you can use the timeout/timeoutlen (not ttimeout/ttimeoutlen) settings to cause mappings to time out.

e.g.

Try the following:

:set timeout timeoutlen=1000 " These are the defaults
:nnoremap xd dd

Press xd. It will delete a line.

Now just press x. Nothing will happen for one second: Vim is waiting to see whether you are typing the xd mapping. Then, after one second, the mapping will time out, and a single character will be deleted.

0

The correct answer would be

set timeoutlen=200

HTH

  • Yes, It does. But it actually gives a timeout for both keyodes and shortcuts and I don't want that on my shortcuts. However thanks for your answer. Maybe someone can guide better. – Cy8099 Nov 13 '17 at 20:05
  • What exactly do you mean when you say shortcut? – mike Nov 13 '17 at 20:06
  • Keycodes are the own vim shortcuts that they can help us to code faster for example: dd or p are the own vim keycodes but shortcuts are these that we set them in vimrc (like PasteToggle). keycodes don't need to hold one key and press another but shortcat need to hold some keys and press something else for example Ctrl+L However this is my definition of that. – Cy8099 Nov 13 '17 at 20:17

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.