cc: [email protected]
Subject: Re: Re: [ast-users] Ksh93 quivalence of Vim mapping `inoremap jj
<ESC>'?
--------
> vim uses a timeout for such mappings so that you can still type
> in two consecutive "j" if you type slowly. While the KEYBD trap
> can be used for processing arbitrary long key combinations, it is
> not possible to implement a timeout which means you'd loose the
> ability to type in a regular "j".
>
You can implement a timeout. The script below has a half second timeout.
In English the script say that if you typed a j in insert mode then
if the previous character was j and was type in less that a half second
ago, then backspace of the previous j and enter an escape. Otherwise
record the time that the j was typed.
====================cut here===========================
float ed_s=0
function jj
{
if [[ ${.sh.edchar} == j && ${.sh.edmode} == $'\e' ]]
then if [[ ${.sh.edtext: -1:1} == j ]] && (((SECONDS-ed_s)<.5))
then .sh.edchar=$'\b\e'
else ((ed_s=SECONDS))
fi
fi
}
trap jj KEYBD
====================cut here===========================
David Korn
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users