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á!
Frage
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?
Lösung
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á!
Andere Tipps
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:
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)