将地图jj映射到inputrc中的Esc(readline)

时间:2011-07-27 03:02:23

标签: bash vim vi zsh readline

如何在inputrc中将 jj 映射到 Esc ,以便使用GNU Readline(python,mongoshell,...)获取应用程序

使用以下方法在zsh上正常工作:

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

这是我当前的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

1 个答案:

答案 0 :(得分:28)

你应该重新排列inputrc,以便评论的行在set keymap vi-insert之后。

像这样:

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