Get grep results like ctrl-]

2 views
Skip to first unread message

gbog

unread,
Nov 22, 2008, 6:52:50 AM11/22/08
to vim_use
Hi Vim users,

I'm looking for a way to grep from inside vim. I'm aware of :grep
command but I'm not satisfied with the way the results are handled:
they are all loaded as "errors" like if I used a compiler. I would
like the grep result to be displayed the same way as when I do Ctrl-],
then I type the number of the hit, and it opens as a new buffer.

Any cue?

Thanks.

Ben Schmidt

unread,
Nov 22, 2008, 7:07:43 AM11/22/08
to vim...@googlegroups.com

I don't know of a way you can make :grep work like :tselect with tags.

But perhaps it would suit you to do

:copen

and then scroll with your cursor in that window and hit Enter on the
match you want to go to. Do you know about that?

To make it more convenient you could wrap the :grep command in some user
command to automate the opening of the quickfix window (:copen) and have
an autocommand to close it when it is left or map to close it when you
press Enter on an item (perhaps--don't know how that would interact with
Vim's current behaviour for Enter in a quickfix--it might already be a
map of some kind).

Ben.

Yegappan Lakshmanan

unread,
Nov 22, 2008, 11:25:12 AM11/22/08
to vim...@googlegroups.com

You can use the Grep Vim plugin which provides the above functionality
and other additional features:

http://vim.sourceforge.net/scripts/script.php?script_id=311

- Yegappan

gbog

unread,
Nov 25, 2008, 2:21:49 AM11/25/08
to vim_use
On Nov 23, 12:25 am, "Yegappan Lakshmanan" <yegapp...@gmail.com>
wrote:
Thanks, it looks like the Grep Vim plugin is what I was looking for.
One little problem though, I'm used to type :E to get the file
explorer, and now this command is ambiguous, matches Egrep also. I
only use Grep, not Egrep, Fgrep or Agrep, so is there a way to
disallow them?

>
> - Yegappan

Ben Schmidt

unread,
Nov 25, 2008, 7:17:50 AM11/25/08
to vim...@googlegroups.com
> Thanks, it looks like the Grep Vim plugin is what I was looking for.
> One little problem though, I'm used to type :E to get the file
> explorer, and now this command is ambiguous, matches Egrep also. I
> only use Grep, not Egrep, Fgrep or Agrep, so is there a way to
> disallow them?

Well, one way is to just delete those commands in a script that you're
sure will run after the grep plugin. Assuming it's
~/.vim/plugin/grep.vim, I suggest putting the following in
~/.vim/after/plugin/grep.vim (create all necessary directories, too):

:delcommand Egrep
:delcommand Fgrep
:delcommand Agrep

Ben.

Reply all
Reply to author
Forward
0 new messages