:vimgrep 和 MacVim 中的快速修复窗口
我正在从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我在使用 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.我通常不使用 vimgrep,我使用两个插件之一:
Ack 或 grep。也许使用这两者之一会更幸运。
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.
您可以使用
:cnext
和:cprevious
在快速修复列表中移动。我发现 unimpaired 中的映射非常有用,所以]q< /code> 表示
:cnext
,[q
表示:cprevious
。如果您只想要映射而不是整个未受损的插件,请将以下内容放入您的 .vimrc 文件中。
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.
如果我理解正确,您想要搜索项目中许多文件中的特定字符串,然后对该字符串进行一些修改,然后返回到原始窗口并且(如果需要)再次执行相同的过程?
如果不是这种情况,请忽略我的帖子,否则请使用 cscope。
使用以下命令构建 cscope 数据库:
cscope -Rb
在项目根目录中。这将创建cscope.out
文件打开 vim 并使用以下命令添加 cscope 数据库:
:cs add
查找字符串为:
:cs fs
从命令 3 结果中转到您想要的文件并进行所需的修改。
再次使用步骤 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.
Build the cscope Data base using:
cscope -Rb
in your project root directory. This will createcscope.out
fileopen vim and add the cscope database using:
:cs add
find the string as:
:cs f s
Go to file of your wish from the command 3 result and do the required modifications.
Again use step 3, or press
ctrl + ^
to go back to your original file.德里尔所建议的可能是一个解决方案。我遇到了同样的问题,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.
如果我没记错的话,问题是 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.
:colder
和:cnewer
命令可用于导航到以前/较新的快速修复(错误)列表。来自 vim 帮助:
:colder
:cnewer
The
:colder
and:cnewer
commands can be used to navigate to previous/newer quickfix (error) lists.From the vim help:
:colder
:cnewer