Vim ex 模式下 Readline 的 vi 模式

发布于 2024-08-08 07:18:46 字数 216 浏览 3 评论 0原文

让我们看看我能否解释一下自己。

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你げ笑在眉眼 2024-08-15 07:18:46

不确定我是否理解您要做什么,但这可能类似于在正常模式下点击 q:

Not sure if I understand what you're trying to do, but it might be something like hitting q: in normal mode?

远昼 2024-08-15 07:18:46

对于几乎在任何地方(包括在 shell 命令行上)使用 Vim 或 vi 绑定的用户来说,当您离开该环境时,确实会很痛苦。如果您习惯了 vi 绑定超光速,那么返回和弦来跳过单词和其他操作是痛苦且缓慢的。操作系统的默认绑定也有所不同,例如,Mac 支持 option-arrow 而不是 control-arrow,这增加了痛苦。

但有一个地方也发生了这种情况,这确实令人不安:Vim 本身。在 Vim 中工作并使用 : 进入命令模式时,将返回默认的 readline 编辑。和弦全部重新来一遍。如何解决这个问题?

简单:当处于“正常”模式时,即四处导航时,输入 q:

  • Vim 会将您带到完整 Vim 全屏编辑体验的底部,转到为您的生活
  • 此外,命令历史记录可在缓冲区中的前几行中使用
  • 您可以随意复制和粘贴行并编辑命令
  • 在“command”或“ex”模式下执行命令只需在要执行的行上按 ENTER
  • 在空行上按 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 of control-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:

  • Vim will drop you at the bottom of a full Vim full screen editing experience, go for your life
  • Additionally the command history is available on previous lines in the buffer
  • You can yank and paste lines and edit the commands as much as you wish
  • To execute a command in "command" or "ex" mode just hit ENTER on the line you want to execute
  • Hitting enter on an empty line closes the buffer and does nothing
  • But this is just another buffer so you can quit it as usual with :q as well
  • Although ESC leaves the "ex" command line, ESC in the buffer will not leave the buffer, because it's an actual buffer

The q prefix is used to introduce macro recording, so the q: 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文