Bash's vim mode, not vi

2019-03-15 01:32发布

I was fascinated when I discovered vi-like bash's editing mode. One can easily toggle it by issuing set -o vi command. But is there any way to toggle vim-like mode?

I mean when you are in a vi-like mode you can press v key and edit your commands in a fully functional vi editor's window but I would like to know how to force bash to start vim editor instead of vi because of the perks vim provides us (visual selection, additional commands etc)?

标签: bash vim vi
2条回答
家丑人穷心不美
2楼-- · 2019-03-15 02:17

If you set EDITOR variable, in bash you can press Ctrl-x ctrl-e to edit your current command line in your EDITOR e.g. vim

EDIT

the ctrl-x ctrl-e is for emacs mode commandline editing, which is the default one. If you have already set it to vi mode, you could do what you have said, pressing the v. If you want to open the cmd line in vim, you have to set the EDITOR variable (in your .bashrc for example)

Personally I edit command line in emacs mode, even though vim is my main (and only) editor.

查看更多
做自己的国王
3楼-- · 2019-03-15 02:23

In your .bashrc, put the following line:

export VISUAL=/usr/bin/vim

If you want vim in many other contexts too, such as in git, you should also set EDITOR:

export EDITOR=/usr/bin/vim
查看更多
登录 后发表回答