Vim searching through all existing buffers

2020-05-19 04:04发布

When dealing with a single file, I'm used to:

/blah
do some work
n
do some work
n
do some work

Suppose now I want to search for some pattern over all buffers loaded in Vim, do some work on them, and move on. What commands do I use for this work flow?

标签: vim
8条回答
Luminary・发光体
2楼-- · 2020-05-19 04:53

Another approach:

:call setqflist([])           " clear quickfix list
:silent bufdo grepadd! foo %  " edit foo in command-line history window
:cw                           " view search results

Or mapped:

cmap bbb call setqflist([]) \| silent bufdo grepadd!  %<C-F>$hha
查看更多
够拽才男人
3楼-- · 2020-05-19 04:54

I would open all the buffers in a new tab using the following two commands:

:tab sp
:bufdo sp

Then search through each file one by one and close its window when you are done (use :q or :close). Use CTRL+W_ to maximize each window as you are working in it. When you're finished and you close the last window, the tab page will close and you'll be dropped back wherever you were before you decided to do the search.

查看更多
登录 后发表回答