Vi Key Bindings in Rails Console

A while back I was working with ./script/console and exclaimed, “I wish I could use vi keys in this thing!!” Apparently, I didn’t know enough about readline.

The Rails console uses the infamous “readline” library for user input. This means anything you can do with readline, you can do in the Ruby console, or *any* other program that uses readline. So you want vi key bindings in console? No problem, just make (or update if you already have it) a file called “.inputrc” in your home directory and put the following one-liner in it:

set editing-mode vi

Gotta love that!