Hi,
On 12/3/06, Bob Rossi <[EMAIL PROTECTED]> 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.
- Yegappan