Peter Michaux wrote:
Hi Tony,

Thanks for all the info.

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.

Yes, using the :vimgrep command (Vim 7 and some versions of Vim 6) or the external "grep" command (earlier versions):

        :vimgrep /pattern/g ./**/*.[ch] " search the list of files
                                        " for the /pattern/
        :copen                          " open quickfix window

The second command above splits the Vim screen horizontally, with at bottom a window containing one line per match. Hit <Enter> on any line and the corresponding file is opened above the quickfix window, with the cursor on the corresponding match. Or use the commands

        :cfirst
        :cnext
        :cprevious
        :clast

to navigate the list of matches, with or without opening the quickfix window. When done, use

        :cclose

(regardless of which window is current at the time) to close the quickfix 
window.



I don't know Textmate. Vim beats hands down any other GUI editor /I/ know, but
I guess they aren't the same as those you're accustomed to.

It seems Textmate is the one GUI that I keep hearing is winning over
long-time vi and emacs users.

Thanks again.

Peter


Best regards,
Tony.
--
Murphy's Law of Research:
        Enough research will tend to support your theory.

Reply via email to