<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ruslan&#39;s Tech Blog</title>
    <link>https://blog.bekenev.net/tags/emacs-vim.html</link>
    <description>Software development related stuff</description>
    <language>en-us</language>
    <lastBuildDate>Sat, 17 Sep 2022 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.bekenev.net/tags/emacs-vim/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Vim Tabs in Emacs</title>
      <link>https://blog.bekenev.net/2022/09/17/vim-emacs-tabs.html</link>
      <pubDate>Sat, 17 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://blog.bekenev.net/2022/09/17/vim-emacs-tabs.html</guid>
      <description>&lt;p&gt;Immediately few things to mention.&lt;/p&gt;&#xA;&lt;p&gt;First: we&amp;rsquo;re going to talk about Tabs as in &amp;ldquo;UI element&amp;rdquo;. Not indentation.&#xA;&lt;br/&gt;&#xA;Second: Tabs in Vim and Emacs are not supposed to be used as tabs in many other editors.&lt;/p&gt;&#xA;&lt;h2 id=&#34;vim-tabs&#34;&gt;Vim Tabs&lt;/h2&gt;&#xA;&lt;p&gt;Vim tabs aren&amp;rsquo;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.&lt;/p&gt;&#xA;&lt;p&gt;Vim tabs were designed to hold &amp;ldquo;workspaces&amp;rdquo; or logical group of files/buffers/splits, quickfix windows or other &amp;ldquo;vim ui&amp;rdquo; elements.&lt;/p&gt;&#xA;&lt;p&gt;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.&lt;/p&gt;&#xA;&lt;p&gt;Now somebody in your company chat asks for a help and you as a nice person want to take a look.&#xA;&lt;br/&gt;&#xA;You do &lt;code&gt;:tabnew&lt;/code&gt; and new fresh &amp;ldquo;workspace&amp;rdquo; is opened. You then go to a file your colleague was asking for, view it, open one more split for tests or docs, vimgrep for stuff and it&amp;rsquo;s all happening in new fresh &amp;ldquo;workspace&amp;rdquo;. When you&amp;rsquo;re done you just do &lt;code&gt;:tabclose&lt;/code&gt; and you&amp;rsquo;re back to you first main workspace with your 3 splits where everything is untouched &lt;strong&gt;which smooths context switching a lot&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;emacs-tabs&#34;&gt;Emacs Tabs&lt;/h2&gt;&#xA;&lt;p&gt;Switching to any editor from Vim I always felt missing Vim-like tabs functionality and I felt the same in Emacs too.&#xA;Fortunately starting with Emacs27 we have few tab modes built-in and one of them is &lt;code&gt;tab-bar-mode&lt;/code&gt; (default prefix &lt;code&gt;C-x t&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;p&gt;Turns out I can use &lt;code&gt;tab-bar-mode&lt;/code&gt; pretty similarly to vim tabs.&lt;/p&gt;&#xA;&lt;p&gt;The only difference is in Vim when all but one tab is closed the tab-bar gets hidden. Emacs tab-bar dosn&amp;rsquo;t do it.&lt;/p&gt;&#xA;&lt;p&gt;But fortunately it&amp;rsquo;s Emacs so add this advice to your &lt;code&gt;init.el&lt;/code&gt; and now tab-bar gets hidden when there is only one tab left.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(advice-add &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;tab-bar-close-tab&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            :after&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            (lambda (&lt;span style=&#34;color:#66d9ef&#34;&gt;&amp;amp;rest&lt;/span&gt; r) (if (&lt;span style=&#34;color:#a6e22e&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;length&lt;/span&gt; (tab-bar-tabs)))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                  (tab-bar-mode &lt;span style=&#34;color:#ae81ff&#34;&gt;-1&lt;/span&gt;)))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#39;&lt;/span&gt;((name &lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;hide-tabbar-if-one-tab&amp;#34;&lt;/span&gt;)))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In case you don&amp;rsquo;t like how Emacs tabs look or behave you can try &lt;a href=&#34;https://depp.brause.cc/eyebrowse/&#34;&gt;https://depp.brause.cc/eyebrowse/&lt;/a&gt; package that sounds the same to me but its &amp;ldquo;tabs&amp;rdquo; are shown in the modeline.&lt;/p&gt;&#xA;&lt;p&gt;Its styles probably can be customized but with my theme and modeline there is no way to understand what &amp;ldquo;workspace&amp;rdquo; is currently active.&#xA;&lt;br/&gt;&#xA;On the other hand tab-bar is also looking pretty bad (which is also customizable).&lt;/p&gt;&#xA;</description>
    </item>
  </channel>
</rss>
