2. Is there a built-in way to search for a pattern in all currently
loaded buffers?
Cheers,
Eric
It's not possible now.
I personally doubt it would be planned for future inclusion either, but I'm most
certainly not the authority on that!
> 2. Is there a built-in way to search for a pattern in all currently
> loaded buffers?
I'm pretty sure there isn't.
I'd love to make a feature request, though...could :vimgrep be modified so that
the filename is optional, and if omitted, it will use the text of the current
buffer (quite possibly not saved to disk). Then you could do
:call setqflist([])
:bufdo vimgrepadd /whatever/
to achieve that.
Even without the feature built in, it wouldn't be too hard to make a vimscript to
do it, though. I think this might do:
:call setqflist([])
:bufdo g/whatever/call
\ setqflist([{'bufnr': bufnr('%'), 'lnum': line('.'), 'text': getline('.')}],'a')
It wouldn't take too much more work to make this into a custom command, and it
could do with various improvements, I'm sure.
Ben.
Send instant messages to your online friends http://au.messenger.yahoo.com
Further to my earlier post...I wonder whether local argument lists would suit your
purposes? Quite possibly not, I guess, but it's worth mentioning. They are
documented around
:help :arglocal
>
> Eric Tetz wrote:
>> 1. I often find myself wishing a tab could have an independent buffer
>> list, so I could use tabs to organize a large working set of files
>> into manageable subsets. Is this possible now? Maybe in the future?
>
> It's not possible now.
>
> I personally doubt it would be planned for future inclusion either, but I'm most
> certainly not the authority on that!
At the simplest, it should be possible to enhance one of the buffer
explorer scripts such that they will keep track of the original tab
number in which the buffer was created, but the lack of identity for
tabs and the lack of certain tab events would make it rather tricky to
implement.
>
>> 2. Is there a built-in way to search for a pattern in all currently
>> loaded buffers?
>
> I'm pretty sure there isn't.
>
> I'd love to make a feature request, though...could :vimgrep be modified so that
> the filename is optional, and if omitted, it will use the text of the current
> buffer (quite possibly not saved to disk). Then you could do
>
> :call setqflist([])
> :bufdo vimgrepadd /whatever/
>
> to achieve that.
>
> Even without the feature built in, it wouldn't be too hard to make a vimscript to
> do it, though. I think this might do:
>
> :call setqflist([])
> :bufdo g/whatever/call
> \ setqflist([{'bufnr': bufnr('%'), 'lnum': line('.'), 'text': getline('.')}],'a')
>
> It wouldn't take too much more work to make this into a custom command, and it
> could do with various improvements, I'm sure.
>
I attempted to do this long back in my greputils plugin:
http://www.vim.org/scripts/script.php?script_id=1062
The :BufGrep, :ArgGrep and :WinGrep commands are meant for this, but
something might have been broken lately and some functionality might
not be working correctly, sorry haven't been working much in vim lately
so not sure about the current state myself. I still recommend giving it
a try.
--
Hari
That's a bummer, because it's potentially a very powerful feature that
is currently nothing more than a way to save window layouts.
> Even without the feature built in, it wouldn't be too hard to make a
> vimscript to do it, though. i think this might do:
But that won't let you search through buffer text that has not been
saved to a file, right? I'd like to be able to say "vimgrep pattern
%*" (or something like that) which meant "grep loaded buffers".
On Feb 7, 2008 5:49 AM, Ben Schmidt <mail_ben...@yahoo.com.au> wrote:
>
> Eric Tetz wrote:
> > 1. I often find myself wishing a tab could have an independent buffer
> > list, so I could use tabs to organize a large working set of files
> > into manageable subsets. Is this possible now? Maybe in the future?
>
> It's not possible now.
>
> I personally doubt it would be planned for future inclusion either, but I'm most
> certainly not the authority on that!
>
> > 2. Is there a built-in way to search for a pattern in all currently
> > loaded buffers?
>
> I'm pretty sure there isn't.
>
> I'd love to make a feature request, though...could :vimgrep be modified so that
> the filename is optional, and if omitted, it will use the text of the current
> buffer (quite possibly not saved to disk). Then you could do
>
> :call setqflist([])
> :bufdo vimgrepadd /whatever/
>
> to achieve that.
>
> Even without the feature built in, it wouldn't be too hard to make a vimscript to
> do it, though. I think this might do:
>
> :call setqflist([])
> :bufdo g/whatever/call
> \ setqflist([{'bufnr': bufnr('%'), 'lnum': line('.'), 'text': getline('.')}],'a')
>
You can also use the following commands:
:call setqflist([])
:bufdo g/<pattern>/caddexpr expand("%") . ":" . line(".") . ":" .
getline(".")
- Yegappan
No, it should work on unsaved text. It just uses the :g command which searches the
text in the buffer, executes a command on every line that matches, and the command
I gave it was to add to the quickfix list.
Cheers,