tags:

views:

178

answers:

3

I'm trying to get multiple tabs in windows like vim does it. In vim tabs aren't tied to buffers and you can have multiple tabs each with multiple splits and buffers in them. What I've found so far is:

  • tabbar: shows all tabs.
  • winring: doesn't show tabs in the window and is clunky to use (have to name each tab first). This is the closest to what I want.

Does anyone have any ideas if this is possible? Tabs + emacs is hard to search for; most of what I find are discussions of spaces vs tabs :)

Update: This pic http://christianrobinson.name/images/vim7-split-tabs.png shows the kind of thing I want. Multiple tabs and a bunch of split buffers on each tab.

A: 

tabbar is by far the most popular package I think, but only shows tabs for buffers with the same mode you're editing (for instance, if you're working in a file in python-mode, it'll show tabs for all python-mode buffers only). That's the default behavior anyway; I'm pretty sure you could customize that if you wanted to. But my impression is that a popular way to manage multiple buffers in Emacs is with ibuffer and ido-mode. For instance, my .emacs customizations include

(require 'ido)
(ido-mode t)
(global-set-key "\C-x\C-b" 'ibuffer)
Stephen
Busy watching the video, thanks
MDCore
Yeah, that video is absolutely nothing like what I'm looking for.
MDCore
Oh, yeah... it's not about enabling tabs but a different way to manage buffers in emacs. If you give it a try you may lose interest in tabs for emacs ;).
Stephen
I work with groups of files so for example I will have tab 1 with (products controller split in 2, view of products list) and tab 2 with (categories controller, categories view, products controller) etc. Having keys to switch between tabs and only tabs is better than using separate frames and having to alt-tab via the window manager which mixes my editor app with the other dozen apps that are open
MDCore
So you're single-framing it... I was never that dedicated but I did go through a phase of using tabbar (for years) and then a few months of elscreen. It's a nice package, but its default behavior kept surprising me so I searched around and settled on the tools mentioned above, including winner-mode and save-window-configuration-to-register. And to switch among multiple frames I've mapped 'other-frame to `C-c o` (to parallel `C-x o`, which switches between windows). Actually I wrote a wrapper to 'other-frame so that `C-u C-c o` will switch frames in the reverse direction.Just some extra options
Stephen
A: 

You can do C-x 4 c to clone a buffer : create an indirect buffer that is a twin copy of the current buffer. It allows you to show the same buffer with different major-mode enabled in different windows.

Then with tabbar you can have different tabs showing the same buffer in different modes for example.

Jérôme Radix
Well the problem with tabbar is that each buffer has a set of tabs along the top. I want a per-window set of tabs, with each tab being able to show multiple buffers, all split up.
MDCore
To clarify using emacs terminology, OP seeks per-frame tabs, each tab showing one or more emacs "windows" (emacs shows 1 buffer per window). From the TabBarMode wiki: *Tab bar mode is implemented using a special emacs display area at the top of Emacs Window, not Emacs Frame. (For example, if you split a window into 3 panes, each will have a tab bar).*
Chadwick
+2  A: 

I use something called ElScreen, which allows me to do what you are looking for. I actually also wanted this feature from VIM as well when I decided to start using Emacs.

The following is the code that I use for ElScreen, I even used the same type of keybindings as you would use in VIM. Control-C, followed by tabe or tabd to emulate the :tabe or :tabd in VIM.

To iterate through the next screen, or tab in this case, I use Control Meta _ and Control Meta +.

;; ---------------------------------------
;; load elscreen
;; ---------------------------------------
(load "elscreen" "ElScreen" t)

;; F9 creates a new elscreen, shift-F9 kills it
(global-set-key (kbd "C-c t a b e") 'elscreen-create)
(global-set-key (kbd "C-c t a b d") 'elscreen-kill)

;; Windowskey+PgUP/PgDown switches between elscreens
(global-set-key (kbd "C-M-_") 'elscreen-previous)
(global-set-key (kbd "C-M-+") 'elscreen-next)

Here's an example of the tab setup in action:

First Screen.

alt text

Second Screen:

alt text

You can have split buffers using C-x3 and C-x2 in a tab :)

Mahmoud Abdelkader
This is exactly what I wanted. Just as a note this clashes a little with ecb. If I have a left layout the tabs appear in the ecb directory tree. I had to move ecb to the right for the tabs to be in the edit window.
MDCore
@MDCore: these are window configuration management - again not what you're asking for directly, but `save-window-configuration-to-register` and `winner-mode` are simpler tools aimed at accomplishing the same task (managing window configurations).
Stephen
Dang... now elscreen is showing tabs on each split. Am I doing something wrong?
MDCore
Yes, that's a small problem I've encountered. What you have to do is C-x 0 to get rid of the split, then re-split again, C-x 3 or C-x 2, then everything will be fine. Remember, to auto-balance the splits, you can do C-x + and that should take care of it
Mahmoud Abdelkader
Hmm, it's happening to me no matter how I split, resplit or balance. At least it's progress :)
MDCore
Ah... if I open a file in the new split the tabs in the split disappear. Guess I need to log a bug; except the library hasn't been updated since 2007.
MDCore
I like this library so much I'm honestly thinking about forking it and maintaining it. I guess this is my first bug ;)
Mahmoud Abdelkader
Let me know where the repository is :)
MDCore