Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

map jj to Esc in inputrc (readline)

How can I map jj to Esc in inputrc so it gets picked up by apps using GNU Readline (python, mongoshell, ...)

all works fine on zsh using:

bindkey -M viins 'jj' vi-cmd-mode 

this is my current inputrc:

set editing-mode vi set keymap vi  # turn off the stupid bell set bell-style none $if mode=vi     set keymap vi-command     "gg": beginning-of-history     "G": end-of-history     #"jj": vi-movement-mode     set keymap vi-insert     "\C-w": backward-kill-word     "\C-p": history-search-backward $endif 
like image 654
jassinm Avatar asked Jul 27 '11 03:07

jassinm


1 Answers

You should rearrange the inputrc so the commented line comes after set keymap vi-insert.

Like this:

set bell-style none $if mode=vi     set keymap vi-command     "gg": beginning-of-history     "G": end-of-history     set keymap vi-insert       #notice how the "jj" movement is     "jj": vi-movement-mode     #after 'set keymap vi-insert'?     "\C-w": backward-kill-word     "\C-p": history-search-backward $endif 
like image 176
Ehtesh Choudhury Avatar answered Sep 20 '22 03:09

Ehtesh Choudhury