grep

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

grep

Don Stefani
Hello,

I need some help with grep and vim.

From a shell I type 'grep -n 'function' *.php' and it searches within
my current dir.
From vim using :!, how can I search the file I have in the current
working buffer,
and output a list of lines with my search word in it?

Thanks,
 - dstefani
Reply | Threaded
Open this post in threaded view
|

Re: grep

Tim Chase-2
> how can I search the file I have in the current working
> buffer, and output a list of lines with my search word in it?


The common way of doing this is

:g/regexp/#

which will return the matching lines, all numbered.  If you need
to do something with these results other than simply seeing them,
you can use the "redir" command before/after.

        :help :#
        :he redir
        :he :g

should get you pointed in the right direction.

HTH,

-tim
Reply | Threaded
Open this post in threaded view
|

Re: grep

Don Stefani-2
Very cool, I'm off to try it now!

Thanks.

PS: I do appreciate the help here, thanks to vim being vim, I'm not forced
to use it since nothing else compares to it. And now it's available time vs.
learning. Thanks again.

- dstefani


On 6/23/05 3:00 PM, "Tim Chase" <[hidden email]> wrote:

>> how can I search the file I have in the current working
>> buffer, and output a list of lines with my search word in it?
>
>
> The common way of doing this is
>
> :g/regexp/#
>
> which will return the matching lines, all numbered.  If you need
> to do something with these results other than simply seeing them,
> you can use the "redir" command before/after.
>
> :help :#
> :he redir
> :he :g
>
> should get you pointed in the right direction.
>
> HTH,
>
> -tim


Reply | Threaded
Open this post in threaded view
|

Re: grep

Hari Krishna Dara
In reply to this post by Don Stefani

On Thu, 23 Jun 2005 at 5:10pm, Don Stefani wrote:

> Very cool, I'm off to try it now!
>
> Thanks.
>
> PS: I do appreciate the help here, thanks to vim being vim, I'm not forced
> to use it since nothing else compares to it. And now it's available time vs.
> learning. Thanks again.
>
> - dstefani

Take a look at my greputils.vim plugin from vim.org. The BufGrep,
ArgGrep and WinGrep commands make the job of running :bufdo, :argdo and
:windo with g/re/p command a breeze. It also provides GrepBufs commands
to run g/re/p on specified buffers. The output is given in a quickfix
like window from which you can jump to the file.

--
HTH,
Hari

>
>
> On 6/23/05 3:00 PM, "Tim Chase" <[hidden email]> wrote:
>
> >> how can I search the file I have in the current working
> >> buffer, and output a list of lines with my search word in it?
> >
> >
> > The common way of doing this is
> >
> > :g/regexp/#
> >
> > which will return the matching lines, all numbered.  If you need
> > to do something with these results other than simply seeing them,
> > you can use the "redir" command before/after.
> >
> > :help :#
> > :he redir
> > :he :g
> >
> > should get you pointed in the right direction.
> >
> > HTH,
> >
> > -tim
>
>
>
>


               
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com