Question

How can I do VI style navigation in rails console?

In my .bash_profile i do set -o vi and then in my terminals I enjoy vi style navigation. I can do dd to delete a line, cmd+$ to jump to end of line, etc etc.

I want to get the same thing in rails console?

Was it helpful?

Solution

You need to set the editing-mode to vi. The easiest way to do that is simply creating the file .inputrc in your home folder and add the mode:

$ echo "set editing-mode vi" >> ~/.inputrc

And voilá!

OTHER TIPS

I had the same issue although using inputrc didn't work. The reason it didn't work though is because I was using zsh as my shell. Zsh does NOT use inputrc for setting the input mode. Hence if you want to use vi editing mode in rails console and you're using zsh as your shell do the following:

Add the following to your ~/.zshrc

bindkey -v

References:

  1. https://wiki.archlinux.org/index.php/Zsh#Key_bindings
  2. http://zsh.sourceforge.net/Guide/zshguide04.html

just wanted to point out that there is a gem called rb-readline

this gem breaks rails console's ability to work in vi mode

(my project had bundled it because this gem was once necessary for byebug to work)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top