Vim ex 模式下 Readline 的 vi 模式
让我们看看我能否解释一下自己。
我在 bash 中使用 vi 模式,这真的很棒,因为我已经习惯了 Vi。
当我在 vim 中并输入 : (进入 ex 模式)时,因为我习惯了 bash 的 vi 模式,所以我觉得必须使用这种模式就像使用 bash 的“常规”方式一样缓慢。
问题是:有没有办法像 bash(或 readline)vi 模式一样使用 vim 的 ex 模式?
Let's see if I can explain myself.
I use vi-mode in bash, which is really great since I'm used to Vi.
When I'm inside vim and type : (to go to ex mode), since I'm used to the vi-mode from bash, I feel the slowliness of having to use this mode like the "regular" way of using bash.
Question is: is there a way of using vim's ex-mode like bash's (or readline) vi-mode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定我是否理解您要做什么,但这可能类似于在正常模式下点击
q:
?Not sure if I understand what you're trying to do, but it might be something like hitting
q:
in normal mode?对于几乎在任何地方(包括在 shell 命令行上)使用 Vim 或 vi 绑定的用户来说,当您离开该环境时,确实会很痛苦。如果您习惯了 vi 绑定超光速,那么返回和弦来跳过单词和其他操作是痛苦且缓慢的。操作系统的默认绑定也有所不同,例如,Mac 支持
option-arrow
而不是control-arrow
,这增加了痛苦。但有一个地方也发生了这种情况,这确实令人不安:Vim 本身。在 Vim 中工作并使用
:
进入命令模式时,将返回默认的 readline 编辑。和弦全部重新来一遍。如何解决这个问题?简单:当处于“正常”模式时,即四处导航时,输入
q:
ENTER
:q 也是如此
ESC
离开了“ex”命令行,但是缓冲区中的ESC
不会离开缓冲区,因为它是一个实际的缓冲区q 前缀用于引入宏记录,因此
q:
变体对于输入“ex”命令行的记录来说是完美的助记符。请注意,进入缓冲区编辑模式的
q:
与:q
非常相似!有时您可能会不小心碰到它;-) 现在您知道如何摆脱它了!当然,齐格登很久以前就有了这个答案,但它非常稀疏,但话又说回来,问题也是如此。如果齐格登在他的答案中添加了这一额外的细节,我将很乐意删除此答案,以便可以找到一个好的答案。
For users that use Vim or vi bindings almost everywhere, including on their shell command line, it really hurts when you leave that environment. If you're used to the vi bindings hyperdrive, going back to chords for skipping words and other manoeuvres is painful and slow. Operating systems also differ on their default bindings so Mac, for instance, supports
option-arrow
instead ofcontrol-arrow
, adding to the pain.But there is one place where this also happens where it's really upsetting: in Vim itself. When working in Vim and entering command mode using
:
the default readline editing returns. Chords all over again. How to fix this?Simple: When in "normal" mode, that is, when navigating around, type
q:
ENTER
on the line you want to execute:q
as wellESC
leaves the "ex" command line,ESC
in the buffer will not leave the buffer, because it's an actual bufferThe
q
prefix is used to introduce macro recording, so theq:
variant is perfectly mnemonic for entering recording of an "ex" command line.Note that
q:
to enter the buffer editing mode is very similar to:q
! You may have hit that by accident sometimes ;-) Now you know how to get out of it!Zigdon had this answer a long time ago, of course, but it's pretty darn sparse, but then again, so is the question. If Zigdon adds this extra detail to his answer I'll be happy to delete this answer so that there can be one good answer.