How do I make vi editing-mode work in IRB when usi

2019-01-23 05:06发布

I "set editing-mode vi" in my .inputrc on my Mac OS system, which allows vi editing in IRB. When I'm using a RVM Ruby, the IRB sessions don't process this directive.

Does anyone know a solution?

标签: rvm vi irb
4条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-23 05:09

Using RVM-installed Ruby 1.9.3 on Mountain Lion, I was able to get vi key bindings in irb by adding bind -v to ~/.editrc . I installed Ruby 2.0 using RVM on the same system and irb was stuck in emacs mode. Adding set editing-mode vi to ~/.inputrc got vi key bindings working in irb on Ruby 2.0 for me.

查看更多
霸刀☆藐视天下
3楼-- · 2019-01-23 05:16

Have you got set -o vi set, either at the command-line or in one of your startup scripts? That turns it on for the shell. I have both "set editing-mode vi" and set -o vi and have Vi-like editing in IRB.


EDIT:

Try creating ~/.editrc, put bind -v in it. Snow Leopard has support for editline built in, so that might be what IRB is using.

Try man 5 editrc for more info.

查看更多
我命由我不由天
4楼-- · 2019-01-23 05:24

These days, I'm using rbenv-installed Ruby 2.5 on MacOS Mojave and the way to get vi key bindings in irb is to add set editing-mode vi to ~/.inputrc.

It appears that adding bind -v to ~/.editrc isn't required and doesn't help.

查看更多
We Are One
5楼-- · 2019-01-23 05:26

As mentioned before, you can add bind -v in your ~/.editrc.

The problem with this, as you may or may not have noticed is that this removes your ability to use tab completion. If you want to keep tab completion you can add: bind \\t rl_complete to your ~/.editrc.

查看更多
登录 后发表回答