Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
  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:

share|improve this question

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)
share|improve this answer
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. – Paweł Gościcki Oct 18 '12 at 21:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .