sponsor Vim development Vim logo go to HTTPS page Vim Book Ad

buffergrep : Grep buffers, not files

 script karma  Rating 39/19, Downloaded by 1803    Comments, bugs, improvements  Vim wiki

created by
erik falor
script type
Searches for strings in open buffers.  Instead of supplying a filename wildcard to direct the search, the grep command will search in open buffers which may or may not be represented by a file on the disk.  Moreover, since buffers are searched, changes that have not been saved to disk are scanned.  Unlisted, quickfix, and help buffers are skipped.

Each grep command uses the same syntax as the builtin :vimgrep and :lvimgrep commands.  Results are displayed in the quickfix list.

The following commands are defined:

Bgrep - searches all buffers listed with the :buffers command, skipping over unlisted, quickfix, and help buffers.  Analagous to :bufdo.
Agrep - searches all buffers listed with the :args command.  Analagous to :argdo.
Wgrep - searches all buffers visible on the screen (current tab page only).  Analagous to :windo.
Tgrep - searches all buffers open on any tabpage.  Analagous to :tabdo.


Bgrep /jhonka/  "find string 'jhonka' in all loaded buffers.
Wgrep |foo|j  "find string 'foo' in all buffers currently on the screen, but don't jump to first match.
Tgrep !bar!g  "find string 'bar' in all buffers visible in all tabpages, and list each occurance of 'bar', not just the first one on a line.
Agrep baz    "find string 'baz' in all buffers from the args list; specifying the pattern this way means you can't use flags.

Of course, the argument isn't just a literal string, it is a regular expression.  You man use any valid Vim regular expression atoms in your search.
install details
Copy into $HOME/.vim/plugins

Rating scripts is only available on the HTTPS page

script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
buffergrep.vim 1.1 2008-07-17 7.0 erik falor Bugfixes: TabSearch now reaches all files,
Regex delimiter around arguments now optional
buffergrep.vim 1.0 2008-06-02 7.0 erik falor Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo