Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim — How can I search buffers?

Tags:

vim

search

buffer

I am looking for some command like:

:b1!g/something_here/

where I supposedly search for a word "something_here" in the buffer "b1". How can I do it?

like image 941
Léo Léopold Hertz 준영 Avatar asked May 09 '09 16:05

Léo Léopold Hertz 준영


People also ask

How do I navigate buffers in Vim?

Pressing Alt-F12 opens a window listing the buffers, and you can press Enter on a buffer name to go to that buffer. Or, press F12 (next) or Shift-F12 (previous) to cycle through the buffers.

How do I close all buffers in Vim?

Just put it to your . vim/plugin directory and then use :BufOnly command to close all buffers but the active one.

How does vi editor use buffers?

Whenever you delete something from a file, vi keeps a copy in a temporary file called the general buffer. You can also delete or copy lines into temporary files called named buffers that will let you reuse those lines during your current vi work session.

How many cut and paste buffers does vi have?

vi has 26 buffers, named ``a'' through ``z'', where it can store text temporarily. You can use buffers to: store text for insertion elsewhere in the current file.


2 Answers

I often do:

:rew
:bufdo 0
:bufdo g/something here/
:ls

The last :ls allows me to see all the buffers that are not positioned on line 1

like image 131
John Weldon Avatar answered Sep 24 '22 14:09

John Weldon


Well, go to buffer b1 and

:g/something here/

For searching through all open buffers there are various plugins, for which I think would be best if you took a peek on www.vim.org

Edit: like this one - buffergrep
And my personal favorite for all kinds of searching: compview

like image 6
Rook Avatar answered Sep 23 '22 14:09

Rook