Reputation: 7386
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?
Upvotes: 2
Views: 3007
Reputation: 19805
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.
Upvotes: 0
Reputation: 7386
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.
Upvotes: 0
Reputation: 4119
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.
Upvotes: 0
Reputation: 41
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.
Upvotes: 4
Reputation: 45087
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>
Upvotes: 3
Reputation: 12413
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.
Upvotes: 3
Reputation: 4585
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 create cscope.out
file
open 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.
Upvotes: 0