Emacs Tab-bar-mode

To enable tab bars:

(tab-bar-mode 1)
(desktop-save-mode 1)

desktop-save-mode enables tabs between sessions

toggle-frame-tab-bar enable the display of the Tab Bar on some frames and disable it on others

=C-x t = the prefix key for creating tabs of various kinds

C-x t 2 adds a new tab next to the currently active tab. By default the new tab is a clone of the currently active tab.

You can control the choice of the buffer displayed in a new tab by customizing the variable tab-bar-new-tab-choice.

With tab-bar-new-tab-choice what is the difference between:

current buffer - opens the current buffer in the new tab
current window - duplicate the content of the current window
buffer - opens a specific buffer like scratch
directory - opens a dedicated dired buffer of one's choice
file - opens a dedicated file of one's choice
function - runs a function of one's choice, i.e. customize the behavior of new tabs in Emacs beyond the default options

To control the names of new tabs: tab-bar-tab-name-function

To switch to an existing buffer in a tab: switch-to-buffer-other-tab C-x t b

To find a specific file in a tab: find-file-other-tab C-x tf

To find a specific directory: dired-other-tab C-x t d

Very important command

C-x t t is an important PREFIX command that you run BEFORE running any another command. A new buffer of your choice is then created in a new tab.

tab-bar-new-tab-to defines WHERE to position the newly created tab

C-x t 0 close selected tab (buffer stays open)
C-x t 1 close all tabs except currently selected tab
C-TAB switches between tabs
S-C-TAB previous tab
C-x t r rename current tab

To change the colrs of the current tab:

At present I cannot easily see which tab is the current tab because the colors are all light greys. To change the colors of current tab:

;; Change colors of current tab
(set-face-attribute 'tab-bar-tab nil
                    :background "dark orange" :foreground "black")

(set-face-attribute 'tab-bar-tab-inactive nil
                    :background "gray" :foreground "black")

Return to Home