mapping with delay processing

2006-10-29 Thread Yakov Lerner

How can I make mapping or abbrev that behaves as follows:
when I type echo  (echospace) and I type nothing else within
1 second, it adds '' (so it becomes 'echo '). If I continue typing
quickly after 'echo ', then [] is not added. I'm sure it's possible.

Yakov


Re: mapping with delay processing

2006-10-29 Thread John Degen
- Original Message 
From: Yakov Lerner [EMAIL PROTECTED]
To: vim users list vim@vim.org
Sent: Sunday, October 29, 2006 12:38:36 PM
Subject: mapping with delay processing

How can I make mapping or abbrev that behaves as follows:
when I type echo  (echospace) and I type nothing else within
1 second, it adds '' (so it becomes 'echo '). If I continue typing
quickly after 'echo ', then [] is not added. I'm sure it's possible.

Yakov


see :h sleep

hth John
 
-- 
Sane sicut lux seipsam,  tenebras manifestat, sic veritas norma sui,  falsi 
est. -- Spinoza







Re: mapping with delay processing

2006-10-29 Thread Benji Fisher
On Sun, Oct 29, 2006 at 01:38:36PM +0200, Yakov Lerner wrote:
 How can I make mapping or abbrev that behaves as follows:
 when I type echo  (echospace) and I type nothing else within
 1 second, it adds '' (so it becomes 'echo '). If I continue typing
 quickly after 'echo ', then [] is not added. I'm sure it's possible.
 
 Yakov

 Untested:  use an abbreviation that defines two autocommands:

:augroup Hack
:au CursorHoldI * execute normal a\\Esc
:au CursorHoldI,InsertLeave,CursorMovedI * au! Hack
:agroup END

What I did test is that CursorMovedI is triggered when you insert a
character.  Thus both autocommands are cleared after 'updatetime' or the
first typed character (or cursor movement or leaving Insert mode).  I am
not sure whether the :normal command will work.  Of course, you can also
have the abbreviation change updatetime and have the autocommands
restore it.

HTH --Benji Fisher