💾 Archived View for g.codelearn.me › 2022-09-17-vim-emacs-tabs.gmi captured on 2023-01-29 at 02:29:41. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Vim Tabs in Emacs

Immediately few things to mention.

First: we're going to talk about Tabs as in "UI element". Not indentation.

Vim Tabs

Vim tabs aren't supposed to be tabs similar to other editors where you have a file per tab and then switch those tabs with your mouse (???!). There are buffers for that.

Vim tabs were designed to hold "workspaces" or logical group of files/buffers/splits, quickfix windows or other "vim ui" elements.

For instance you may be working on a project issue and you have your tests in one split and actual code in another. Maybe some docs in 3d one.

Now somebody in your company chat asks for a help and you as a nice person want to take a look.

Emacs Tabs

Switching to any editor from Vim I always felt missing Vim-like tabs functionality and I felt the same in Emacs too. Fortunately starting with Emacs27 we have few tab modes built-in and one of them is `tab-bar-mode` (default prefix `C-x t`)

Turns out I can use `tab-bar-mode` pretty similarly to vim tabs.

The only difference is in Vim when all but one tab is closed the tab-bar gets hidden. Emacs tab-bar dosn't do it.

But fortunately it's Emacs so add this advice to your `init.el` and now tab-bar gets hidden when there is only one tab left.

(advice-add 'tab-bar-close-tab
            :after
            (lambda (&rest r) (if (= 1 (length (tab-bar-tabs)))
                                  (tab-bar-mode -1)))
            '((name . "hide-tabbar-if-one-tab")))

In case you don't like how Emacs tabs look or behave you can try

https://depp.brause.cc/eyebrowse/

package that sounds the same to me but its "tabs" are shown in the modeline.

Its styles probably can be customized but with my theme and modeline there is no way to understand what "workspace" is currently active.