Bash的vim模式,而不是vi [英] Bash's vim mode, not vi
问题描述
当我发现类似vi的bash的编辑模式时,我着迷了.可以通过发出 set -o vi
命令轻松地切换它.但是有什么方法可以切换类似vim的模式吗?
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?
我的意思是,当您处于类似vi的模式时,可以按 v
键并在功能齐全的vi编辑器窗口中编辑命令,但是我想知道如何强制bash启动< vim 编辑器而不是 vi
,因为 vim
为我们提供了额外的好处(可视化选择,其他命令等)?
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)?
推荐答案
如果设置了 EDITOR
变量,则在bash中,您可以按 Ctrl-x ctrl-e
进行编辑您当前的 EDITOR
中的命令行,例如 vim
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
ctrl-x ctrl-e
用于emacs模式的命令行编辑,这是默认设置.如果已经将其设置为vi模式,则可以按 v
进行操作.如果要在vim中打开cmd行,则必须设置 EDITOR
变量(例如,在.bashrc中)
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)
我个人以emacs模式编辑命令行,即使vim是我的主要(也是唯一)编辑器.
Personally I edit command line in emacs mode, even though vim is my main (and only) editor.
这篇关于Bash的vim模式,而不是vi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!