Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tabbed windows on Emacs

Tags:

emacs

tabs

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.

like image 738
MDCore Avatar asked Sep 15 '10 09:09

MDCore


People also ask

How do you add tabs in Emacs?

To manually insert a tab in Emacs, use ctrl-Q TAB. control-Q causes the next key to be inserted rather than interpreted as a possible command.

How do I open a second window in Emacs?

To open a new frame, select Make New Frame from the Files menu or press C-x 5 2 (for make-frame). Emacs makes a new frame containing the current buffer and puts it on top of the current frame.


2 Answers

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 :)

like image 135
Mahmoud Abdelkader Avatar answered Sep 24 '22 02:09

Mahmoud Abdelkader


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) 
like image 23
hatmatrix Avatar answered Sep 24 '22 02:09

hatmatrix