:vimgrep 和 MacVim 中的快速修复窗口

发布于 2024-10-10 15:42:44 字数 319 浏览 1 评论 0原文

我正在从 Textmate 转换为 MacVim,并且正在努力复制 Textmate 的“在项目中查找”功能。我可以使用 :vimgrep /foo/g **/*.py 进行搜索,并使用 :cope 打开快速修复窗口。从那里我可以毫无问题地导航并打开相应的比赛。

我的问题是,如果我打开的匹配项不正确,我无法找到一种方法在不再次运行整个搜索的情况下返回搜索结果窗口。我可以再次使用 :cope 打开 Quickfox 窗口,但它只包含 1 个结果,即我刚刚打开的文件。

搜索多个文件和管理结果的一般工作流程是什么?

I'm converting from Textmate to MacVim and I'm struggling with replicating Textmate's 'Find in Project' feature. I can search just fine with :vimgrep /foo/g **/*.py and open the quickfix window with :cope. From there I can navigate to and open the appropriate match without issue.

My problem is that if the match I opened isn't the correct one, I can't find a way of bringing back the search results window without running the entire search again. I can open the quickfox window with :cope again but it only contains 1 result, the file I just opened.

What is the general workflow for searching multiple files and managing the results?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(7

染柒℉ 2024-10-17 15:42:44

我在使用 QuickFix 时遇到了同样的问题,在注意到您关于导致 QuickFix 窗口立即清除的 filetype Plugin indent on 的评论后,将此跟踪到一个插件:jslint,该插件每次都设置 QuickFix 窗口javascript 文件被打开或写入。您可能已经为某些打开的文件类型启用了类似的插件。

I ran into the same issue with quickfix, and after noticing your comment about filetype plugin indent on causing the quickfix window to clear immediately, tracked this to a plugin: jslint, which was setting the quickfix window every time a javascript file was opened or written to. You might have had a similar plugin enabled for some open filetype.

倥絔 2024-10-17 15:42:44

我通常不使用 vimgrep,我使用两个插件之一:
Ackgrep。也许使用这两者之一会更幸运。

I don't usually use vimgrep, I use one of two plugins:
Ack or grep. Maybe you have better luck using one of these two.

み青杉依旧 2024-10-17 15:42:44

您可以使用 :cnext:cprevious 在快速修复列表中移动。我发现 unimpaired 中的映射非常有用,所以 ]q< /code> 表示 :cnext[q 表示 :cprevious
如果您只想要映射而不是整个未受损的插件,请将以下内容放入您的 .vimrc 文件中。

nnoremap ]q :cnext<cr>
nnoremap [q :cprevious<cr>

You can move through the quickfix list with :cnext and :cprevious. I find the mappings from unimpaired very useful so ]q for :cnext and [q for :cprevious.
If you want just the mappings and not the whole unimpaired plugin put the following in your .vimrc file.

nnoremap ]q :cnext<cr>
nnoremap [q :cprevious<cr>
心头的小情儿 2024-10-17 15:42:44

如果我理解正确,您想要搜索项目中许多文件中的特定字符串,然后对该字符串进行一些修改,然后返回到原始窗口并且(如果需要)再次执行相同的过程?

如果不是这种情况,请忽略我的帖子,否则请使用 cscope。

  1. 使用以下命令构建 cscope 数据库:
    cscope -Rb 在项目根目录中。这将创建 cscope.out 文件

  2. 打开 vim 并使用以下命令添加 cscope 数据库:

    :cs add

  3. 查找字符串为:

    :cs fs

  4. 从命令 3 结果中转到您想要的文件并进行所需的修改。

  5. 再次使用步骤 3,或按 ctrl + ^ 返回原始文件。

If I understand it correctly, You want to search for a particular string which can be in many files in your project and then do some modification with that string, then return back to original window and (if required), do the same process again?

If that's not the case, ignore my post else use cscope.

  1. Build the cscope Data base using:
    cscope -Rb in your project root directory. This will create cscope.out file

  2. open vim and add the cscope database using:

    :cs add

  3. find the string as:

    :cs f s

  4. Go to file of your wish from the command 3 result and do the required modifications.

  5. Again use step 3, or press ctrl + ^ to go back to your original file.

轻拂→两袖风尘 2024-10-17 15:42:44

德里尔所建议的可能是一个解决方案。我遇到了同样的问题,quickfix 内容消失了,结果发现它是由 pyflakes.vim linter 引起的。 linter 试图为 lint 错误创建快速修复条目,但它的作用只是从搜索中清除快速修复内容。我为 linter 插件设置了一个禁用快速修复支持的选项,它解决了问题。

What dreel is suggesting is probably a fix. I had the same issue with quickfix content disappearing and it turns out it was being caused by the pyflakes.vim linter. The linter was trying to create quickfix entries for lint errors, but it just had the effect of clearing quickfix content from searches. I set an option for the linter plugin that disabled quickfix support and it fixed the problem.

肥爪爪 2024-10-17 15:42:44

如果我没记错的话,问题是 Vim 脚本/插件以某种方式干扰了快速修复窗口的正常操作。我意识到,在处理此类 Vim 问题时,最好将 Vim 剥离到最基本的部分,看看问题是否仍然存在。

If I recall correctly, the issue was that a Vim script/plugin was somehow interfering with the normal operation of the quickfix window. I've realised that when dealing with Vim issues like this it's good practice to strip Vim back to the bare essentials and see if the problem still exists.

痴情 2024-10-17 15:42:44

:colder:cnewer 命令可用于导航到以前/较新的快速修复(错误)列表。

来自 vim 帮助:

:colder

:col[der] [count]   Go to older error list.  When [count] is given, do
            this [count] times.  When already at the oldest error
            list, an error message is given.

:cnewer

:cnew[er] [count]   Go to newer error list.  When [count] is given, do
            this [count] times.  When already at the newest error
            list, an error message is given.

The :colder and :cnewer commands can be used to navigate to previous/newer quickfix (error) lists.

From the vim help:

:colder

:col[der] [count]   Go to older error list.  When [count] is given, do
            this [count] times.  When already at the oldest error
            list, an error message is given.

:cnewer

:cnew[er] [count]   Go to newer error list.  When [count] is given, do
            this [count] times.  When already at the newest error
            list, an error message is given.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文