3

When in Readline apps with vim mode enabled in ~/.inputrc (set editing-mode vi) is there a way to bind the <Up> arrow key in vi-insert mode? To display previous history item, for example. It seems I have to press ESC key first, only then it works.

Here's my attempt at making it work (~/.inputrc):

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

Also note, that when I press Ctrl+v and then <Up>, it prints ^[[A.

I did manage to have it working like I want in zsh: http://paulgoscicki.com/archives/2012/09/zsh-vi-mode-with-emacs-keybindings/

0

What you want works in bash already: I can use up-arrow to display the previous history item in vi-insert mode. The following command shows how it is configured. Perhaps you are confusing history-search-backward with history-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)
1
  • You're confusing READLINE with shell. I have no problems configuring the desired behaviour in my shell of choice, which is zsh. I have problems with Readline apps, like Postgresql console, IRB, etc. Oct 18 '12 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.