How to control the behavior acted by vim after searching in files with grep ?

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

How to control the behavior acted by vim after searching in files with grep ?

Lenin Lee
Hi there,

I used grep to search in files, but vim always opens the first matching file.

I wonder how to control this behavior, is there a way to stop opening a match automatically or open it in a new split window ?

Thanks

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: How to control the behavior acted by vim after searching in files with grep ?

Matt Wozniski-2
On Tue, Dec 15, 2009 at 9:05 PM, Lenin Lee wrote:
> Hi there,
> I used grep to search in files, but vim always opens the first matching
> file.
> I wonder how to control this behavior, is there a way to stop opening a
> match automatically

Use the ! flag.

    :grep! foo *.c

> or open it in a new split window ?

Split the window before doing the search:

    :split | grep foo *.c

~Matt

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: How to control the behavior acted by vim after searching in files with grep ?

Lenin Lee
Thank you very much, it solves my problem !

2009/12/16 Matt Wozniski <[hidden email]>
On Tue, Dec 15, 2009 at 9:05 PM, Lenin Lee wrote:
> Hi there,
> I used grep to search in files, but vim always opens the first matching
> file.
> I wonder how to control this behavior, is there a way to stop opening a
> match automatically

Use the ! flag.

   :grep! foo *.c

> or open it in a new split window ?

Split the window before doing the search:

   :split | grep foo *.c

~Matt

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php



--
初从文,三年不第。遂习武,校场发一矢,中鼓吏,逐之出。后学医,有所成,自撰一良方,服之,卒。

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: How to control the behavior acted by vim after searching in files with grep ?

MarcWeber
Excerpts from Lenin Lee's message of Wed Dec 16 05:45:50 +0100 2009:
> Thank you very much, it solves my problem !
Also remember that there are ctrl-o (go to last cursor location) and
ctrl-^ (toggle buffer). That's what I'm using.

Marc Weber

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php