jump to navigation

Adding vi keybindings to irb, script/console, and mysql October 19, 2008

Posted by John Dewey in Rails, Ruby.

I loves me my vi, and sun keyboard mappings (although it drives people crazy when they peer on my macbook).

Add the following on OS X 10.5:

john@emopop:~> cat .editrc
bind -v

This will work for OS X 10.4 and other operating systems:

john@emopop:~> cat .inputrc 
set editing-mode vi


1. reidmix - October 24, 2008

emacs or death!

2. Ben Oakes - December 22, 2008

So nice.

I had just been using “set -o vi” in my .bashrc, but this takes care of that and everything else.

3. Jeff - February 15, 2009

Thanks for this. For some reason, .inputrc (the first thing I tried) doesn’t seem to work on OS X 10.5. Did they switch from readline to editline or something?

4. John Dewey - February 15, 2009

Hi Jeff –

OS 10.5 uses libEdit vs gnu readline. I believe that is why you need
.editrc in this case.


5. yogsototh - June 11, 2009

Thank you so much. This is perfect :-). I used only bindkey -v in zsh, but this is far better.

6. Neal Clark - November 14, 2009

if you’re like me and can’t live without ^L clearing the screen (in irb and script/console), you’ll want this second line too:

bind -v
bind ^L ed-clear-screen

7. david wright - November 24, 2009

I finally admitted to myself that set editing-mode vi in .inputrc was no longer working

Many Thanks for the great tip

8. Mark Scholtz - September 27, 2010

Great tip! Been looking for this answer for ages, but I have a rather annoying issue. In irb I no longer have autocompletion after adding “bind -v” to my editrc. Can anyone suggest a fix. It’s driving me crazy. Would be so amazing if I could have the best of both 🙂

9. Doug McInnes - September 28, 2010

First one works on 10.6 still 🙂

10. Stephane Liu - October 3, 2010

Many thanks for this tip. Been going crazy trying to figure it out.

11. Michael Glass - March 16, 2011


add this:
bind \\t rl_complete

12. Mark Scholtz - March 16, 2011


Thanks for the tip. I actually fixed the problem a while ago. If I remember correctly the solution was to reinstall readline for the version of Ruby that I was running. I’m using RVM to manage Ruby versions and I believe that I followed the help offered on the RVM site here: http://rvm.beginrescueend.com/packages/readline/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: