Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Open each buffer in a new tab

Tags:

vim

I am wondering how I can open all of the current buffers in vi(m) in new tabs. I know that you can edit your vimrc file to do something like this, but I'd prefer just to be able to run a command when needed. I can do it manually by chaining the new tab and open buffer commands, such as:

:tabnew | b 1 

But I would prefer a more automatic approach.

like image 432
josh-fuggle Avatar asked Mar 30 '11 01:03

josh-fuggle


2 Answers

The way to go is:

:tab sball 

From the help:

"sball: Rearrange the screen to open one window for each buffer in the buffer list... When the |:tab| modifier is used new windows are opened in a new tab, up to 'tabpagemax'."

Without the |:tab| modifier, it open each buffer in split view.

:sball 

or to open at most 6 of them

:6sball 

etc.

like image 71
sehe Avatar answered Sep 26 '22 15:09

sehe


you can assign a mapping to this command:

:bufdo tab split 
  • explanation:
    • bufdo [command] apply the [command] to all buffers
    • tab split take the current buffer and open a tab with it

finally, to map this:

map ,bt :bufdo tab split<CR> 

greets

like image 22
fespinozacast Avatar answered Sep 24 '22 15:09

fespinozacast