One thing I often do (but rely on the command line to do) is searching/grepping in multiple files.Is there a way to display search results for all the open buffers?Ideally, I'd like to have a new split buffer containing result location and snippet much like grep does. For example (/statistics):models/statistics.php: /*! \file   statistics.phpcontrollers/stats.php: $this->load->model('statistics');controllers/stats.php: // Query statistics...controllers/stats.php: $num_exams = $this->statistics->countExams();As a bonus, I'd like to be able to search for the term under the cursor, pretty much like gd does.
How to show search results for all open buffers
search;multiple files
You can use :vimgrep /pattern/ {files} to populate the quickfix list with matching patterns. The problem is that :vimgrep files option doesn't directly allow for buffers. You can use:%   Is replaced with the current file name.       *:_%* *c_%*#   Is replaced with the alternate file name.     *:_#* *c_#*#n  (where n is a number) is replaced with        *:_#0* *:_#n*    the file name of buffer n.  #0 is the same as #.     *c_#n*##  Is replaced with all names in the argument list   *:_##* *c_##*    concatenated, separated by spaces.  Each space in a name    is preceded with a backslash.#<n (where n is a number > 0) is replaced with old    *:_#<* *c_#<*    file name n.  See |:oldfiles| or |v:oldfiles| to get the    number.                         *E809*    {only when compiled with the |+eval| and |+viminfo| features}Another option is to write a script that generates a file list from :buffers. Per this SO post with a slight tweek we get:function! BuffersList()  let all = range(0, bufnr('$'))  let res = []  for b in all    if buflisted(b)      call add(res, bufname(b))    endif  endfor  return resendfunctionfunction! GrepBuffers (expression)  exec 'vimgrep/'.a:expression.'/ '.join(BuffersList())endfunctioncommand! -nargs=+ GrepBufs call GrepBuffers(<q-args>)You can now call :GrepBufs <expression> and get the standard :vimgrep output but using the buffers instead.Update If you would like to call GrepBuffers using the value under the cursor add this new mapping.nnoremap <leader>z :call GrepBuffers(<C-R><C-W>)<CR>When you are in normal mode type <leader>z and you'll :vimgrep the cursor word over your open buffers.