Saturday, August 28, 2010

Re: Run lgrep then immediately open Location list

On Fri, Aug 27, 2010 at 6:13 AM, Oivvio Polite <oivvio@polite.se> wrote:
> I'm moving on from vim basics to the fun stuff. Just found out about vimgrep et. al.
> I've set grepprg to ack-grep and after executing :lgrep I'd like to go
> immediately to the "Location list" buffer, without having to press enter
> after the results come back from ack-grep and without having to
> explicitly execute :lopen.

This command might work for you:

:command! -nargs=+ MyLgrep execute 'silent lgrep! <args>' | lopen 42

Note that the '!' form of lgrep means 'do not jump to first match', which may
or may not be what you want.

The location list window doesn't have to be made 42 lines high, of course.

You can then invoke this command like so:

:MyLgrep export ~/.bashrc

to find for example all occurrences of the pattern 'export' in your ~/.bashrc.

You might want to map this to a key sequence:

:nnoremap <Leader>g :MyLgrep

Note that its a tiny bit more convenient if you map to 'MyLgrep ' (with a
trailing space).

Britton

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: