Vim Tips Wiki
Advertisement

Previous TipNext Tip

Tip: #1317 - Open every buffer in its own tabpage

Created: August 25, 2006 4:00 Complexity: basic Author: Groleo Marius Version: n/a Karma: 45/15 Imported from: Tip#1317

If you ever wanted a buffer to be opened into its own tabpage:

:au BufAdd,BufNewFile * nested tab sball 

Many thanks to A.J. Mechelynck for his immense knowledge of vim :)

Comments

Thanks for your great tip. I was searching for a tip which can be the replacement for minibufexplorer plugin.

I modified it to the following so that every file I open from command line with vi also opens in its own tab:

:au BufAdd,BufNewFile,BufRead * nested tab sball 

however when i do :e! to reload the current buffer it always jumps to the last opened tab and reloads it.

Any hint ?

Regards, Rajendra

rbadapanda--AT--gmail.com , August 25, 2006 13:28


I would like to get each tab bound to a buffer. This hint is one step closer to that, but not quite there yet. Say I am browsing code and I hit Ctrl-] to jump to a class definition which opens up a new file in a new tab, then I hit Ctrl-T to go back to the previous code. Now I have two tabs that have the same file loaded. Is there any way to catch the change buffer event, then find the tab that already has that buffer loaded and switch to that tab? To me this seems like the natural way to use tabs, at least it's how I'm used to using them from all other programs I've ever used tabs in. It seems funny that there is no option to have them work in this way in VIM.

MrQBerrt<at>yahoo.com , August 28, 2006 13:49


This seems to does horrid things when I reference the help (e.g., :help :auto): from 1 buffer containing the file I'm editing, I end up with 2, each in their own tab. My original file has been hidden, and I've two windows on the helpfile autocmd.txt - one pointing at start-of-file, the other pointing to the referenced tag.

cej-vim , August 30, 2006 6:51


It also does not work nicely if you use the :Explore command to navigate the file system (which I do all the time). Every time you list a new directory, it opens a new tab. Needless to say the tabs pile up quickly.

Warning: Frustrated Rant Ahead: I have to say that I'm really disappointed in the tab functionality in Vim7.0. I think it is extremely unintuitive in the way it works. And it's a big pain in the a** to have to have to jump through so many hoops like this just to try to get it to work the way it should in the first place.

I was expecting that every file would open in a new tab and everything would just work. Maybe there would be a setting to turn on tabs and that would be it. Alas, no. You have to configure this obvious tab behaviour yourself. And after many tweaks to my .vimrc file and hours of searching the Vim help, vim online, the vim mailing lists and Google, modifying this and tweaking that, I still do not have a satisfactory solution. I've come close, but there's always something that doesn't work.

Along the way I noticed that everyone is trying to do the same thing. Everyone just wants to open a tab for each buffer automatically and have it just work. It seems fairly obvious that tabs should work this way. It surprises me that the developers missed this. End Rant.

nowayjose--AT--mailinator.com , August 31, 2006 14:35


I'm not sure why there's such a problem dealing with tabs - at least I don't find them difficult.

When I open a couple files and I want them to be in individual tabs, I add '-p' to the command ... gvim -p file1 file2... and they all open in their own tabs.

Or, if I don't want that behavior, I ignore that '-p', and vim opens them in buffers but doesn't display them, and then, if I decide I want to split a window and show a particular combination of files in the same tab (or window) I can using the standard (old) splitting methods.

If I have a particular buffer I want to open in a tab, after I've loaded it, I use ':tabfind filename' and vim opens that buffer in a tab. Or, I just open a blank tab (':tabnew') then do a :bu to pull that file into the tab.

Anonymous , August 31, 2006 17:07


Advertisement