在 Vim 的命令行模式下使用普通模式运动 [英] Using normal-mode motions in command-line mode in Vim

查看:28
本文介绍了在 Vim 的命令行模式下使用普通模式运动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在命令行模式下进行模态编辑?

Is modal editing possible in command-line mode?

一些例子:

  • 写完!ls ~/foo/bar我要db删除bar
  • 我执行了上面的命令,现在我想将 ls 更改为 mv 并跳回 $
  • After writing !ls ~/foo/bar I want to db to delete bar
  • I executed the above command and now I want to change ls to mv and jump back to $

推荐答案

默认情况下,您可以在 Vim 上按 Control + f(或查看 set cedit)command-line,它打开命令行窗口,您可以在其中使用普通模式 Vim 编辑键编辑命令.Enter 将运行命令或 Control + c 将返回标准命令行.

By default you can press Control + f (or otherwise see set cedit) when on the Vim command-line, which opens the command-line window where you can edit the command using normal-mode Vim editing keys. Enter will run the command or Control + c will return you to the standard command-line.

因此,在您的具体示例中,您可以在 Vim 命令行上按 Control + f 然后按 db ,它会执行您想要的操作.

So in your specific example, you could press Control + f on the Vim command-line then db and it would do what you want.

当我必须执行更复杂的编辑命令时,我会使用上述方法,因为我对 Vim 编辑键比对替代方法更熟悉.我还发现普通模式的 vim 键更强大.

When I have to do more sophisticated editing commands I use the above approach because I'm more familiar with Vim editing keys than I am with the alternatives. I also find the normal-mode vim keys more powerful.

更多信息见:help c_ctrl-f.

这篇关于在 Vim 的命令行模式下使用普通模式运动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆