<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Michele Campeotto: Tag vim</title>
    <link>http://blog.micampe.it/articles/tag/vim?tag=vim</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>I'm not Winston Wolfe.</description>
    <item>
      <title>Enhanced buftabs Vim Plugin</title>
      <description>&lt;p&gt;After a couple of days using my &lt;a href="http://blog.micampe.it/articles/2007/03/25/tabs-in-vim-and-my-first-plugin"&gt;bufpos&lt;/a&gt; vim plugin together with &lt;a href="http://www.vim.org/scripts/script.php?script_id=1664"&gt;buftabs&lt;/a&gt;, I realized I didn&amp;#8217;t need the buffer numbers in the status line (I can always get them with &lt;code&gt;:ls&lt;/code&gt;), but their position number would have been very useful.&lt;/p&gt;

&lt;p&gt;So here is my &lt;a href="http://micampe.it/files/buftabs.vim"&gt;modified version&lt;/a&gt; with these three changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the tab numbers indicate the the number you have press to get there instead of the buffer number&lt;/li&gt;
&lt;li&gt;improved &lt;code&gt;autocmd&lt;/code&gt; settings to better synchronize the &lt;code&gt;!&lt;/code&gt; modified flag&lt;/li&gt;
&lt;li&gt;different &lt;a href="http://vimdoc.sourceforge.net/htmldoc/cmdline.html#filename-modifiers"&gt;filename shortening mode&lt;/a&gt;, now it is displayed with a path relative to the current or home directory (don&amp;#8217;t set &lt;code&gt;g:buftabs_only_basename&lt;/code&gt; to get that)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have contacted the &lt;code&gt;buftabs&lt;/code&gt; author and the last two will be in the next &lt;code&gt;buftabs&lt;/code&gt; release too.&lt;/p&gt;</description>
      <pubDate>Wed, 28 Mar 2007 10:16:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:e444b8a0-7aee-45a9-a71d-7adbd26d0d0a</guid>
      <author>micampe</author>
      <link>http://blog.micampe.it/articles/2007/03/28/enhanced-buftabs-vim-plugin</link>
      <category>English</category>
      <category>vim</category>
      <category>script</category>
      <category>plugin</category>
      <trackback:ping>http://blog.micampe.it/articles/trackback/1084</trackback:ping>
    </item>
    <item>
      <title>Tabs in Vim and My First Plugin</title>
      <description>&lt;p&gt;One of the most talked about features of Vim7 are &lt;a href="http://www.linux.com/article.pl?sid=07/01/11/2141259"&gt;tabs&lt;/a&gt;, but I don&amp;#8217;t like them very much, I think they should have been given a different name. They could have been called &lt;em&gt;layouts&lt;/em&gt;, for example, because they are very different from what most people expect and much more similar to Eclipse&amp;#8217;s perspectives or NetBeans workspaces than to Firefox tabs.&lt;/p&gt;

&lt;p&gt;I find buffers, which have been in Vim since pretty much forever, are a very convenient way to edit multiple files. You just have to tune them a bit.&lt;/p&gt;

&lt;p&gt;First, you absolutely have to set the &lt;code&gt;hidden&lt;/code&gt; option, so you can switch between buffers without being forced to save them, and then you need some key mappings:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;set hidden
map &amp;lt;C-TAB&amp;gt; :bnext!&amp;lt;CR&amp;gt;
map &amp;lt;C-S-TAB&amp;gt; :bprev!&amp;lt;CR&amp;gt;
map &amp;lt;C-\&amp;gt; :b#&amp;lt;CR&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Use &lt;code&gt;Ctrl-Tab&lt;/code&gt; and &lt;code&gt;Ctrl-Shift-Tab&lt;/code&gt; to navigate through the list of open buffers and &lt;code&gt;Ctrl-\&lt;/code&gt; to quickly toggle between two open files.&lt;/p&gt;

&lt;p&gt;After using this setup for quite some time, about a week ago I found &lt;a href="http://www.vim.org/scripts/script.php?script_id=1664"&gt;buftabs&lt;/a&gt;, a simple plugin that displays the open buffers in the status line. I like simple plugins, my rule is that they have to be useful without me having to actually learn to use them or even remember they are there.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;set laststatus=2
let g:buftabs_in_statusline=1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I then added two more mappings to navigate through buffers, to better match the visual representation &lt;code&gt;buftabs&lt;/code&gt; provides.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;map &amp;lt;C-b&amp;gt; :bprev!&amp;lt;CR&amp;gt;
map &amp;lt;C-n&amp;gt; :bnext!&amp;lt;CR&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With these switching buffers is even easier, as you have a visual indication of which buffer you are going to activate.&lt;/p&gt;

&lt;p&gt;Just one last piece was missing from this picture: most tabs implementations allow you to directly activate a tab by pressing the &lt;code&gt;Alt&lt;/code&gt; key and a number, like Firefox, for example.&lt;/p&gt;

&lt;p&gt;So here comes my first Vim script ever: &lt;a href="http://www.vim.org/scripts/script.php?script_id=1836"&gt;bufpos&lt;/a&gt; is a very simple script that maps &lt;code&gt;Alt-number&lt;/code&gt; keys to activate buffers.&lt;/p&gt;

&lt;p&gt;Note that you don&amp;#8217;t have to use the buffer number &lt;code&gt;buftabs&lt;/code&gt; puts beside the file name, but the position in the buffers list.&lt;/p&gt;</description>
      <pubDate>Sun, 25 Mar 2007 14:05:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:162bb42d-555f-4014-a7cf-58c3c8e81ade</guid>
      <author>micampe</author>
      <link>http://blog.micampe.it/articles/2007/03/25/tabs-in-vim-and-my-first-plugin</link>
      <category>English</category>
      <category>vim</category>
      <category>script</category>
      <category>plugin</category>
      <trackback:ping>http://blog.micampe.it/articles/trackback/1083</trackback:ping>
    </item>
    <item>
      <title>Vim Tango color scheme</title>
      <description>&lt;p&gt;Things you do at the airport while waiting for the cute girl to call the boarding&amp;#8230;&lt;/p&gt;

&lt;p&gt;Finding that a &lt;a href="http://uwstopia.nl/blog/2006/07/tango-terminal"&gt;Tango color scheme for my terminal&lt;/a&gt; was a nice idea, I made one for my Vim too.&lt;/p&gt;

&lt;div style="text-align: center;"&gt;&lt;a href="http://micampe.it/screenshots/tango-vim.png"&gt;&lt;img src="http://micampe.it/screenshots/tango-vim-thumb.png" alt="screenshot" /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;To use the &lt;a href="http://www.vim.org/scripts/script.php?script_id=1686"&gt;Vim Tango color scheme&lt;/a&gt; you have to place the &lt;a href="http://micampe.it/files/tango.vim"&gt;&lt;code&gt;tango.vim&lt;/code&gt;&lt;/a&gt; file in the &lt;code&gt;~/.vim/colors/&lt;/code&gt; directory and &lt;code&gt;colorscheme tango&lt;/code&gt; in your &lt;code&gt;~/.vimrc&lt;/code&gt;.&lt;/p&gt;</description>
      <pubDate>Fri, 20 Oct 2006 10:07:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:83fbead4-0ada-4b00-9bd7-b3338003bbaf</guid>
      <author>micampe</author>
      <link>http://blog.micampe.it/articles/2006/10/20/vim-tango-color-scheme</link>
      <category>English</category>
      <category>vim</category>
      <category>tango</category>
      <category>colorscheme</category>
      <trackback:ping>http://blog.micampe.it/articles/trackback/395</trackback:ping>
    </item>
  </channel>
</rss>
