30

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 shows the kind of thing I want.

enter image description here

Multiple tabs and a bunch of split buffers on each tab.

mit
  • 11,083
  • 11
  • 50
  • 74
MDCore
  • 17,583
  • 8
  • 43
  • 48

3 Answers3

24

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
  • 23,011
  • 5
  • 41
  • 54
  • 2
    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 Sep 16 '10 at 03:27
  • @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). – hatmatrix Sep 16 '10 at 03:42
  • Dang... now elscreen is showing tabs on each split. Am I doing something wrong? – MDCore Sep 16 '10 at 03:46
  • 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 Sep 16 '10 at 07:36
  • Hmm, it's happening to me no matter how I split, resplit or balance. At least it's progress :) – MDCore Sep 16 '10 at 08:50
  • 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 Sep 16 '10 at 09:16
  • 3
    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 Sep 16 '10 at 10:35
  • Let me know where the repository is :) – MDCore Sep 16 '10 at 11:02
  • @MDCore: I'm suffering from exactly the same bug. Very annoying indeed! Did you ever find a fix? – Nicolas Wu Nov 26 '11 at 17:55
  • @NicolasWu Nope. I just live with it now :/ – MDCore Nov 28 '11 at 09:03
4

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)
hatmatrix
  • 42,883
  • 45
  • 137
  • 231
  • 1
    Yeah, that video is absolutely nothing like what I'm looking for. – MDCore Sep 15 '10 at 19:18
  • 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 ;). – hatmatrix Sep 16 '10 at 03:39
  • 1
    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 Sep 16 '10 at 04:12
  • 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 – hatmatrix Sep 16 '10 at 09:45
1

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
  • 10,285
  • 4
  • 34
  • 40
  • 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 Sep 15 '10 at 11:51
  • 1
    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 Sep 15 '10 at 20:11