Peter Michaux said...
> On 2/26/07, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:
> >
> > > If vim does have the concept of a project can I do a project wide
> > > search or search and replace in my project? I find this essential for
> > > refactoring and cleaning up code when I realize what I should have
> > > called a variable.
> >
> > Maybe not as such, but it is easy to implement, almost trivial. Just make a
> > distinct directory tree for each project. Then it is very easy to search
> > and/or replace in all subdirectories of the "project" directory: for 
> > instance,
> >
> >         :args ./**/*.[ch]
> >         :argdo 1,$s/\<ThisVariable\>/thisVariable/g |update
> >
> > replaces ThisVariable by thisVariable (but only as a separate word) in all 
> > *.c
> > and *.h files in the current directory and all its subdirectories to (IIUC) 
> > a
> > depth of 100 levels.
> 
> That doesn't seem almost trivial to me ;) I could live with that if
> needed however.
> 
> My projects do always have a distinct directory tree.
> 
> Would there be a way to review all the found instances in a single
> screen and then link to the real instance in the source? I find this
> feature in Textmate so incredibly useful it might be the one thing
> that keeps me with Textmate. I really want to be able to work with vim
> modes however.

I'm not a vim guru, but I too made the switch from a similar tool to vim 
as yourself, and needed similar functionality. Here's what I do.

I create mappings for the location of projects that I'm working on, 
and/or their parents. So:

  nmap  ,pm   :cd ~\My Documents\My Website\pmwiki<CR>
  nmap  ,web  :cd ~\My Documents\My Website<CR>
  nmap  ,fm   :cd D:\Apache\htdocs\forums\<CR>

To search, I use:

  :vim /search for/ **/*.txt

where :vim is the short form of :vimgrep. However, because previous 
commands are cached, you need only type:

  :vi<Up>

and the last search appears and can be edited.

Once the search completes, type:

  :cw

to open the quickfix window, which shows all the matches. You move 
through the results with :cn and :cp (but also learn <C-o> and <C-i>).

In addition, if you want a 'sidebar' window in which you can list your 
commonly used files, then you might try the workspace plug-in. Once 
setup, it saves a lot of time.

-- 
Cheers,
Marc

Reply via email to