命令行中可编辑的 vimgrep 字符串 [英] Editable vimgrep string in command line

查看:28
本文介绍了命令行中可编辑的 vimgrep 字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常使用 vimgrep 在文件中导航,并且通常使用历史记录中的最后一次搜索来修改搜索模式并再次运行.

I use vimgrep a lot to navigate in files and usually use the last search from the history to modify the search pattern and run it again.

有没有办法在命令行中显示一个可编辑字符串,如下所示,光标已经定位在两个搜索模式斜线之间(并且模式为空)?

Is there a way to display in the command line an editable string like the one below, with the cursor already positioned between the two search pattern slashes (and the pattern being empty)?

:vimgrep//**/*[ch]|copen

我不想使用常量映射(比如 这个 vim 提示) 因为我希望能够添加/更改选项(\c 等).

I don't want to use a constant mapping (like the one at this vim tip) since I want to be able to add/change options (\c etc.).

推荐答案

我建议为此使用命令行窗口(q: 从正常模式打开它),因为您可以使用常规的普通模式按键编辑命令(并且您也可以突出显示语法).

I'd recommend using the command-line window for this (q: opens it from normal mode), since you can edit the command with the regular normal mode keystrokes (and you get syntax highlighting too).

您也可以像在普通缓冲区中一样在历史记录中移动.所以 ?vimgrepnnn... 将搜索并将您移动到所有旧的 vimgrep 命令.

You can also move around in your history just like in a normal buffer. So ?vimgrep<Enter>nnn... will search for and move you to all your old vimgrep commands.

在完成编辑后照常按 ,或按 :q 中止命令并像其他任何操作一样退出窗口.

Just hit <Enter> as normal when you are done editing, or :q<Enter> to abort the command and quit the window like you would any other.

最后,这里有一个映射,可以在命令行窗口中快速调出您的空 vimgrep 模板.

Finally, here's a mapping to quickly bring up your empty vimgrep template in the command-line window.

:nnoremap \v q:ivimgrep<Space>//<Space>**/*[ch]<Bar>copen<Esc>F/;i


参考: :help cmdline-window

这篇关于命令行中可编辑的 vimgrep 字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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