On Wed, 21 Mar 2012 14:31:18 -0400
Taylor Hedberg <[email protected]> wrote:

> > Is it possible to vimgrep all opened buffers, not just the current
> > one?
> Well, :vimgrep really operates on files, not buffers. The `%` in the

Yes, I knew it, however vimgrep with expanding filename by percent
sign made my day :) Very clever.

> command I gave previously expands to the filename of the current buffer.
> You can replace that with a list of files (or a glob pattern, like
> `*.c`) to search over multiple files at once.
> 
> I don't know of any easy way to grep over all open buffers, but you
> could probably come up with a function that does it. Something to this
> effect would probably work (tested, but only a little bit):
> 
>     function! GrepOpenBuffers(pattern)
>         let bufnames = ''
>         for i in filter(range(1, bufnr('$')), 'bufexists(v:val)')
>             let bufnames .= ' ' . bufname(i)
>         endfor
>         execute 'vimgrep /' . a:pattern . '/ ' . bufnames
>     endfunction
>     command! -nargs=1 GrepOpenBuffers call GrepOpenBuffers(<args>)
> 
> Then use the defined command to do the search:
> 
>     :GrepOpenBuffers 'some search pattern'
> 
> Maybe there's a simpler way to do this that I'm overlooking. Hopefully
> someone else will show me up. :)

Thanks! I like more Marcin solution, since it is lot simpler :)

-- 
Roman Dobosz <[email protected]>

-- 
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

Reply via email to