bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash readline remap ESC insert/command mode key


From: Chet Ramey
Subject: Re: Bash readline remap ESC insert/command mode key
Date: Sat, 21 Jan 2012 21:17:32 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 1/19/12 2:25 AM, Roger wrote:
>> bind -m vi-command '"ii": vi-insertion-mode'
>> bind -m vi-insert '"ii": vi-movement-mode'
>>
>>
>> Or the following should work (untested here) using $HOME/.inputrc:
>>
>> $if mode=vi
>>
>>    set keymap vi-command
>>    "ii": vi-insertion-mode
>>
>>    set keymap vi-insert
>>    "ii": vi-movement-mode
>>
>> $endif
> 
> 
> I've just tested the above inputrc by executing a new bash shell instance and 
> the above inputrc statement works, but there is an undesirable effect when 
> using it.
> 
> While in insert mode, pressing the 'i' key only once causes readline to 
> intercept it and not print the 'i' char to screen if only pressed once.  In 
> order to get the 'i' char printed, I need to immediately press any other key 
> following the 'i' char/key so it is not intercepted by readline as it is not 
> a 
> double 'i' key (ie 'ii').

Yes.  It's ambiguous at that point.  Readline can't tell whether or not
you mean 'ii' until you type the second `i'.  If you type something else,
you must not have meant 'ii' and readline can use the original binding
to self-insert.

Readline doesn't add characters bound to a multi-character key sequence to
the editing buffer and perform redisplay, because it will just have to go
back and erase them later in the majority of cases.

I could look at putting in some sort of inter-character timeout, but I
don't know yet how well the code structure lends itself to that.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]