cc: [email protected] 
Subject: Re: [ast-users] Ksh93 quivalence of Vim mapping `inoremap jj <ESC>'?
--------

> When using the Vim editor I have following mapping configured in my vimrc:
> 
> inoremap jj <ESC>
> 
> so I can press `jj' (easier than <ESC>) to go to NORMAL mode from INSERT
> mode when editing files.
> 
> I know ksh93 have the KEYBD trap but I don't know how to use it to meet my
> requirement. So any one has any idear?
> 
> Thanks.
> 
> -Clark
> 
> 

Assuming a half second timeout, then the following should allow jj to work
like escape.  Note that the space is needed before -1 to prevent it from
being treated like the :- operator.

====================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

Reply via email to