开发者

map jj to Esc in inputrc (readline)

开发者 https://www.devze.com 2023-03-23 08:07 出处:网络
How can I map jj to Esc in inputrc so it gets picked up by ap开发者_C百科ps using GNU Readline (python, mongoshell, ...)

How can I map jj to Esc in inputrc so it gets picked up by ap开发者_C百科ps 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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号