问题描述
我希望能够从emacs模式暂时切换到vi模式,因为六模式的有时的更好,但我通常中途通过打字的东西之前,我意识到我想使用vi模式。
I'd like to be able to switch temporarily from emacs mode to vi mode, since vi mode is sometimes better, but I'm usually half-way through typing something before I realize I want to use vi mode.
我不想永久切换到vi模式,因为我通常$命令行页码$ PFER emacs模式,主要是因为它是我已经习惯了,而且多年来许多击键已成为第二性质。 (作为一个编辑,我通常使用emacs在毒蛇模式,这样我可以使用的两个的vi和emacs的按键,因为我发现自己不小心使用它们在vi所有的时间,并拧东西了,因为在某些情况下,我觉得六击键更加难忘和方便,而在其他情况下的emacs。)
I don't want to switch permanently to vi mode, because I normally prefer emacs mode on the command line, mostly because it's what I'm used to, and over the years many of the keystrokes have become second nature. (As an editor I generally use emacs in viper mode, so that I can use both vi and emacs keystrokes, since I found myself accidentally using them in vi all the time, and screwing things up, and because in some cases I find vi keystrokes more memorable and handy, and in other cases emacs.)
推荐答案
您可以创建一个切换由于密钥绑定之间vi模式和emacs模式分开。
You can create a toggle since the key bindings are separate between vi mode and emacs mode.
$ set -o emacs
$ bind '"\ee": vi-editing-mode'
$ set -o vi
$ bind '"\ee": emacs-editing-mode'
现在的Alt-E(或ESC E)将模式之间切换。
Now Alt-e (or Esc e) will toggle between modes.
在您的定义添加此某处 PS1
所以你必须在你的你在哪个模式提示符的指标,它不会立即显示更改你的时候切换模式,但是它会更新时,发出新的提示。
Add this somewhere in your definition for PS1
so you have an indicator in your prompt of which mode you're in. It won't show the change immediately when you toggle modes, but it will update when a new prompt is issued.
$(set -o | grep emacs.*on >/dev/null 2>&1 && echo E || echo V)
这篇关于有没有办法从Emacs的模式切换bash或zsh来vi模式用一个按键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!