I'm using tab-bar-mode in Emacs and noticed that, if there are a lot of tabs, then each tab shrink to accommodate the newer tabs.

What I want to do instead is for the tabs to remain on a fixed width/size, and then show newer tabs on the right side of the tab bar (from looking around, I think it's called "Tab Overflow"?). This is already done in different editor like Geany, so I wonder if there is a way to do it too in Emacs.

Here is my init.el:

;; stop sounds
(setq visible-bell 1)

;; Open File
(global-set-key (kbd "C-o") 'find-file)

;; Save File
(global-set-key (kbd "C-s") 'save-buffer)

;; Cut
(global-set-key (kbd "C-x") 'kill-region)

;; Copy
(global-set-key (kbd "C-c") 'kill-ring-save)

;; Paste
(global-set-key (kbd "C-v") 'yank)

;; Undo
(global-set-key (kbd "C-z") 'undo)

;; Redo
(global-set-key (kbd "C-y") 'undo-tree-redo)

;; Find
(global-set-key (kbd "C-f") 'isearch-forward)

;; Replace
(global-set-key (kbd "C-h") 'query-replace)

;; Go to Line
(global-set-key (kbd "C-g") 'goto-line)

;; Select All
(global-set-key (kbd "C-a") 'mark-whole-buffer)

;; Duplicate Line
(global-set-key (kbd "C-d") (lambda () (interactive) (kill-whole-line) (yank) (yank)))

;; Switch between open files
(global-set-key (kbd "C-<prior>") 'previous-buffer) ; Ctrl + PageUp
(global-set-key (kbd "C-<next>") 'next-buffer)       ; Ctrl + PageDown

;; Quit emacs
(global-set-key (kbd "C-q") 'save-buffers-kill-terminal)

;; Enable tab-bar-mode by default
(tab-bar-mode 1)

(defun new-tab ()
  "Create a new tab with an untitled buffer."
  (switch-to-buffer (generate-new-buffer "untitled")))

(global-set-key (kbd "C-t") 'new-tab)

;; Close Tab
(global-set-key (kbd "C-w") 'tab-close)

;; Next Tab
(global-set-key (kbd "C-<next>") 'tab-next)

;; Previous Tab
(global-set-key (kbd "C-<prior>") 'tab-previous)

(setq tab-bar-show t)

I'm using Emacs 29.1 on Windows 10.

  • 1
    FWIW most people don't use tabs in Emacs at all (they are quite a new addition), and using them to the extent that they're wrapping over multiple lines like that is going to be even less common. (I think tab-bar-mode is a really nice way of encapsulating window configurations, but I can't imagine ever ending up with a situation like your example screenshot in your comments.) You might reconsider what you're using tabs for, and whether you really need them (or need them in the quantities you're currently using), as there will be other options.
    – phils
    Commented Sep 20, 2023 at 8:25
  • ah, yeah I understand that. I actually don't want the tabs to span over multiple lines like what Emacs does, but wanted to emulate/reproduce what other editor do, where they get pushed/overflowed to the left, on the same "line". I'm guessing there is no way to do this with just Elisp currently? @phils basically something like this: i.imgur.com/JvQcrOK.png instead of this: i.imgur.com/tjjpFv2.png Commented Sep 20, 2023 at 8:27
  • 1
    I don't have a specific solution for you, but if you're going to code it yourself then I would start with C-h v tab-bar-tabs-function which allows you to define a custom function to return the list of tabs to be rendered. That function can then return some appropriate slice of the tabs which are actually available, depending on how you've "scrolled" that list (using custom commands which you would also write).
    – phils
    Commented Sep 20, 2023 at 12:23

1 Answer 1


You can disable tab shrinking by using this setting:

(setq tab-bar-auto-width nil)

Then tabs will overflow. You can also set the truncated width by:

(setq tab-bar-tab-name-function 'tab-bar-tab-name-truncated)

When you will use Emacs 30, the same is possible by:

(push 'tab-bar-tab-name-format-truncated tab-bar-tab-name-format-functions)
  • It does overflow now when setting tab-bar-auto-width to nil, but it does not overflow on the same height as the tab? This is what happens when there many tabs in Emacs and this is what I wanted to reproduce/emulate in Emacs. Commented Sep 20, 2023 at 6:49
  • But Emacs needs to show all tabs. How would you see all tabs, when tabs are not truncated, and the tab bar is not overflowed to many lines?
    – link0ff
    Commented Sep 20, 2023 at 6:58
  • so there no way to emulate what Geany does for tabs? so it overflow on the same height as the tab? or on the same "line"? Commented Sep 20, 2023 at 7:05
  • Sorry, I don't know what Geany does. Does it scroll the tab bar like tab-line-mode does in Emacs. Or does it use a drop-down menu to show the tabs that don't fit?
    – link0ff
    Commented Sep 20, 2023 at 7:09
  • 1
    In Emacs you can scroll overflown tabs only on the tab-line. For the tab-bar you can ask for a new feature on the emacs mailing lists, though this is not what such browsers as Chromium do with tabs.
    – link0ff
    Commented Sep 20, 2023 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.