Loading ...
Sorry, an error occurred while loading the content.

Re: timeout, ttimeout, timeoutlen, ttimeoutlen

Expand Messages
  • Bob Rossi
    ... Hi Yegappan, Yes, this is correct. This was confirmed by tpope in #vim at freenode.net. I was able to hit Esc, watch vim get out of insert mode, and then
    Message 1 of 7 , Dec 3, 2006
    • 0 Attachment
      On Sun, Dec 03, 2006 at 07:01:11PM -0800, Yegappan Lakshmanan wrote:
      > Hi,
      >
      > On 12/3/06, Bob Rossi <bob_rossi@...> wrote:
      > >> >> >Hi,
      > >> >> >
      > >> >> >I'm using vim, and I have the default timeout, ttimeout, timeoutlen,
      > >> >> >ttimeoutlen options set. That is, timeout is on, ttimeout is off.
      > >> >> >The manual says:
      > >> >> > 'timeout' 'ttimeout' action
      > >> >> > on on or off time out on :mappings and key codes
      > >> >> >So, this to me means that both mappings and key codes will be timed
      > >out.
      > >> >> >
      > >> >> >My timeoutlen is 1000 and my ttimeoutlen is -1. The manual says:
      > >> >> > ttimeoutlen mapping delay key code delay
      > >> >> > < 0 'timeoutlen' 'timeoutlen'
      > >> >> > >= 0 'timeoutlen' 'ttimeoutlen'
      > >> >> >This tells me that both the mapping delay and the keycode delay will
      > >use
      > >> >> >1000 milliseconds as a timeout. This is 1 second. However, when I'm
      > >in
      > >> >> >insert mode, and hit the ESC key, vim immediately gets out of insert
      > >> >> >mode.
      > >> >> >
      > >> >> >My question is, how does vim know how to move out of insert mode
      > >> >> >immediately, since it should be waiting 1 second to determine if the
      > >> >> >ESC it received was actually an ESC or a key sequence (Home, F1,
      > >...)?
      > >> >> >
      > >> >> >Thanks,
      > >> >> >Bob Rossi
      > >> >> >
      > >> >>
      > >> >> In gvim, and with some terminals in Console Vim, special key codes
      > >don't
      > >> >> start with Esc ; in that case there is no ambiguity. Other than that,
      > >I
      > >> >> don't know, but... "if 't ain' broke, don' fix it."
      > >> >
      > >> >My terminal definatly starts special key codes with ESC, and there is a
      > >> >lot of them. Here is a small sample,
      > >> >
      > >> >$ infocmp xterm
      > >> ># Reconstructed via infocmp from file: /lib/terminfo/x/xterm
      > >> >xterm|X11 terminal emulator,
      > >> > kf4=\EOS, kf40=\EO6S, kf41=\E[15;6~, kf42=\E[17;6~,
      > >> > khome=\EOH, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~,
      > >> >
      > >> >I'd really like to know the answer to this question. I have a feeling
      > >> >vim is not honoring the timeoutlen value that it has documented or that
      > >> >I don't know how to read the documentation.
      > >> >
      > >>
      > >> I think, the following help topics may be relevant here:
      > >
      > >Thank you. I was unaware of all of these.
      > >
      > >> :help xterm-8bit
      > >
      >
      > The following comment is present in the code in the getchar.c file. It looks
      > like in insert mode the escape character is treated specially even though
      > the 'timeout' option is set.
      >
      > /*
      > * get a character: 3. from the user - handle <Esc> in Insert mode
      > */
      > /*
      > * special case: if we get an <ESC> in insert mode and there
      > * are no more characters at once, we pretend to go out of
      > * insert mode. This prevents the one second delay after
      > * typing an <ESC>. If we get something after all, we may
      > * have to redisplay the mode. That the cursor is in the wrong
      > * place does not matter.
      > */
      >
      > To confirm this, I executed the following commands:
      >
      > :set showcmd
      > :set showmode
      > :set timeoutlen=10000
      > :inoremap <Esc>l <C-O>:echo 'Escape ell'<CR>
      >
      > In insert mode, I pressed <Esc> and waited for a few seconds. It
      > looked like Vim came out of insert mode. But when I pressed 'l'
      > after a few seconds (within 10 seconds), then the above map
      > is executed.

      Hi Yegappan,

      Yes, this is correct. This was confirmed by tpope in #vim at
      freenode.net. I was able to hit Esc, watch vim get out of insert
      mode, and then type OH, which completed the Home keycode. Vim
      went back into insert mode, and did the Home action. So, it seems as if
      vim simply appears to have left insert mode, but actually doesn't.

      I think it would be great if this was documented with the ttimeout
      or ttimeoutlen option.

      Thanks for helping resolve this issue.

      Thanks,
      Bob Rossi
    Your message has been successfully submitted and would be delivered to recipients shortly.