Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VimGrep command: So you get the first match, then what?

12 views
Skip to first unread message

Kenny McCormack

unread,
Dec 8, 2009, 2:48:35 PM12/8/09
to
I do: :vimgrep /foo/ *.bar

And it searches through all the *.bat files looking for foo, and leaves
me editing the file with the first match - with a message like (1-5).
How do I go on to the next match/file?

Antoninus Twink

unread,
Dec 8, 2009, 2:51:48 PM12/8/09
to

:cn

See also
:help quickfix

Kaz Kylheku

unread,
Dec 8, 2009, 5:31:36 PM12/8/09
to
On 2009-12-08, Kenny McCormack <gaz...@shell.xmission.com> wrote:
> I do: :vimgrep /foo/ *.bar

Is that new? The old version I'm using has a command which is simply :grep.

I map :grep to do a lid query over the ID database generated by the mkid
program from GNU id-utils:

:set grepprg=lid\ --substring\ --result=grep\ '\\<$*\\>'
:set grepformat=%f:%l:%m

This provides a very fast identifier search over large source trees,
such as the Linux kernel. That, combined with tags, is almost perfect.

> And it searches through all the *.bat files looking for foo, and leaves
> me editing the file with the first match - with a message like (1-5).
> How do I go on to the next match/file?

:cn "next
:cp "previous
:cc <n> "go to the n-th match
:cope "open the matches in a separate window that you can navigate

I suggest to everyone to install the following mappings:

:map ^N :cn^M
:map ^P :cp^M

Rationale: the existing ^N and ^P mappings (next line, previous line)
are next to completely useless, since most users navigate
up and down using other means like arrow keys or hjkl.

Kenny McCormack

unread,
Dec 8, 2009, 5:47:14 PM12/8/09
to
In article <slrnhhtbik...@nospam.invalid>,

OK. So obvious (not!)

>See also
>:help quickfix

I did that - but clearly couldn't decipher what needed to be deciphered.

Mikolaj Machowski

unread,
Dec 9, 2009, 12:15:24 PM12/9/09
to
Kaz Kylheku scripsit:

> On 2009-12-08, Kenny McCormack <gaz...@shell.xmission.com> wrote:
>> I do: :vimgrep /foo/ *.bar
>
> Is that new? The old version I'm using has a command which is simply :grep.

Yes. It uses internal Vim regular expressions engine which is beneficial
especially on Windows.

m.

ps. "New" is relative. It was introduced in 7.0 which was ca. 3 years
ago :)

--
LaTeX + Vim = http://vim-latex.sourceforge.net/
Vim Universal Templates: http://vim.sf.net/script.php?script_id=1078
CLEWN - http://clewn.sf.net

0 new messages