如何绑定〜/ .inputrc(readline)中的箭头以进行vim插入模式?


3

在〜/ .inputrc(set editing-mode vi)中启用了vim模式的Readline应用程序中,是否有办法<Up>vi-insert模式下绑定箭头键?例如,显示上一个历史记录项。看来我必须先按ESC键,然后才能正常工作。

这是我尝试使其工作(〜/ .inputrc):

$if mode=vi
  # INSERT MODE
  set keymap vi-insert
  "\e[A": history-search-backward # up-arrow
  "\e[B": history-search-forward  # down-arrow

另请注意,当我按下Ctrl+v然后<Up>打印时^[[A

我确实设法让它像zsh一样工作:http//paulgoscicki.com/archives/2012/09/zsh-vi-mode-with-emacs-keybindings/

Answers:


0

你想要的是什么bash:我可以用向上箭头在vi-insert模式下显示以前的历史项目。以下命令显示了它的配置方式。也许你感到困惑history-search-backwardhistory-prev

$ bind -m vi-insert -p | grep hist
# beginning-of-history (not bound)
# dynamic-complete-history (not bound)
# end-of-history (not bound)
"\C-s": forward-search-history
# history-and-alias-expand-line (not bound)
# history-expand-line (not bound)
#  (not bound)
# history-search-forward (not bound)
"\eOB": next-history
"\e[B": next-history
# non-incremental-forward-search-history (not bound)
# non-incremental-forward-search-history-again (not bound)
# non-incremental-reverse-search-history (not bound)
# non-incremental-reverse-search-history-again (not bound)
"\eOA": previous-history
"\e[A": previous-history
"\C-r": reverse-search-history
# vi-fetch-history (not bound)

你将READLINE与shell 混淆了。我在选择的shell中配置所需的行为没有问题,这是zsh。我有Readline应用程序的问题,如Postgresql控制台,IRB等。
PawełGościcki12年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.