<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Vim plugins, tips, tricks and tutorials]]></title>
  <link href="http://www.vimninjas.com/atom.xml" rel="self"/>
  <link href="http://www.vimninjas.com/"/>
  <updated>2014-02-21T12:07:39+02:00</updated>
  <id>http://www.vimninjas.com/</id>
  <author>
    <name><![CDATA[Vim Ninjas]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Testing Vim plugins with Vimrunner and RSpec]]></title>
    <link href="http://www.vimninjas.com/2014/02/18/testing-vim-plugins-with-vimrunner-and-rspec/"/>
    <updated>2014-02-18T12:08:00+02:00</updated>
    <id>http://www.vimninjas.com/2014/02/18/testing-vim-plugins-with-vimrunner-and-rspec</id>
    <content type="html"><![CDATA[<p><img src="http://www.vimninjas.com/images/posts/vimrunner/cover.png" alt="Vimrunner" /></p>

<p>Testing Vim plugins is usually a non-trivial task. Many people just don&#8217;t do it because they find it either too painful or simply don&#8217;t know how to do it efficiently. However, if you like Ruby, there is a great tool that will help you write beautiful, easy to read, end-to-end tests for your Vim projects.</p>

<!-- more -->


<h2>Introducing Vimrunner</h2>

<p><a href="https://github.com/AndrewRadev/vimrunner">Vimmrunner</a>, written by <a href="http://andrewradev.com/">Andrew Radev</a>, is a project that spawns Vim instances using Vim&#8217;s <a href="http://vimdoc.sourceforge.net/htmldoc/remote.html#clientserver">client/server</a> functionality and allows you to control them programmatically. It&#8217;s written in Ruby and you can find its docs on <a href="http://rubydoc.info/gems/vimrunner/frames">rubydoc.info</a>. The gem has very intuitive API, and if you are already familiar with the tools in the Ruby ecosystem, you will be up and running in no time. In the next sections I&#8217;ll walk you trough writing a simple spec, in order to showcase some of Vimrunner&#8217;s abilities.</p>

<h2>Getting started</h2>

<p>We&#8217;ll be testing a simple Vim plugin that replaces &#8220;vim&#8221; with &#8220;Vim&#8221; in markdown files:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="k">au</span> <span class="nb">FileType</span> markdown autocmd <span class="nb">BufWritePre</span> <span class="p">&lt;</span>buffer<span class="p">&gt;</span> :%<span class="k">s</span><span class="sr">/vim/</span>Vim/<span class="k">g</span>
</span></code></pre></td></tr></table></div></figure>


<p>To use Vimrunner, you need to install Ruby and your Vim must be compiled with the <code>+clientserver</code> option. For more info, check out <a href="https://github.com/AndrewRadev/vimrunner#requirements">Vimrunner&#8217;s requirements</a></p>

<h2>The setup</h2>

<p>Let&#8217;s start by creating a simple structure for our project:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>mkdir plugin spec
</span><span class='line'><span class="nv">$ </span>touch spec/spec_helper.rb spec/plugin_spec.rb
</span><span class='line'><span class="nv">$ </span>touch Gemfile plugin/sws.vim
</span></code></pre></td></tr></table></div></figure>


<p>The test runner we&#8217;ll be using is RSpec. However, you could use minitest or any other runner that fits your needs. Also, bundler will be required to manage our dependencies.</p>

<p>Gemfile:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">source</span> <span class="s1">&#39;https://rubygems.org&#39;</span>
</span><span class='line'>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;rspec&#39;</span>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;vimrunner&#39;</span><span class="p">,</span> <span class="s1">&#39;0.3.0&#39;</span>
</span></code></pre></td></tr></table></div></figure>


<p>plugin/sws.vim:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="k">au</span> <span class="nb">FileType</span> markdown autocmd <span class="nb">BufWritePre</span> <span class="p">&lt;</span>buffer<span class="p">&gt;</span> :%<span class="k">s</span><span class="sr">/vim/</span>Vim/<span class="k">g</span>
</span></code></pre></td></tr></table></div></figure>


<p>spec/spec_helper.rb:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="nb">require</span> <span class="s1">&#39;vimrunner&#39;</span>
</span><span class='line'><span class="nb">require</span> <span class="s1">&#39;vimrunner/rspec&#39;</span>
</span><span class='line'>
</span><span class='line'><span class="no">Vimrunner</span><span class="o">::</span><span class="no">RSpec</span><span class="o">.</span><span class="n">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
</span><span class='line'>  <span class="c1"># Reuse the Vim server</span>
</span><span class='line'>  <span class="n">config</span><span class="o">.</span><span class="n">reuse_server</span> <span class="o">=</span> <span class="kp">true</span>
</span><span class='line'>
</span><span class='line'>  <span class="n">plugin_path</span> <span class="o">=</span> <span class="no">File</span><span class="o">.</span><span class="n">expand_path</span><span class="p">(</span><span class="s1">&#39;.&#39;</span><span class="p">)</span>
</span><span class='line'>
</span><span class='line'>  <span class="n">config</span><span class="o">.</span><span class="n">start_vim</span> <span class="k">do</span>
</span><span class='line'>    <span class="c1"># Use GVim</span>
</span><span class='line'>    <span class="n">vim</span> <span class="o">=</span> <span class="no">Vimrunner</span><span class="o">.</span><span class="n">start_gvim</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1"># Tell Vimrunner to include our plugin</span>
</span><span class='line'>    <span class="n">vim</span><span class="o">.</span><span class="n">add_plugin</span><span class="p">(</span><span class="n">plugin_path</span><span class="p">,</span> <span class="s1">&#39;plugin/sws.vim&#39;</span><span class="p">)</span>
</span><span class='line'>
</span><span class='line'>    <span class="n">vim</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>Now run <code>bundle install</code> to install our dependencies.</p>

<h2>The spec</h2>

<p>What we would like to do is edit a markdown file, insert some text that contains &#8220;vim&#8221;, then save and assert that &#8220;vim&#8221; has been replaced with &#8220;Vim&#8221;. Here is how you could accomplish this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="nb">require</span> <span class="s1">&#39;spec_helper&#39;</span>
</span><span class='line'>
</span><span class='line'><span class="n">describe</span> <span class="s1">&#39;sws&#39;</span> <span class="k">do</span>
</span><span class='line'>  <span class="n">it</span> <span class="s1">&#39;replaces vim with Vim in markdown files&#39;</span> <span class="k">do</span>
</span><span class='line'>    <span class="c1"># Edit temporary markdown file</span>
</span><span class='line'>    <span class="n">vim</span><span class="o">.</span><span class="n">edit!</span><span class="p">(</span><span class="s1">&#39;test.markdown&#39;</span><span class="p">)</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1"># Insert some text</span>
</span><span class='line'>    <span class="n">vim</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="s1">&#39;vim is awesome. vim vim vim&#39;</span><span class="p">)</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1"># Save the file</span>
</span><span class='line'>    <span class="n">vim</span><span class="o">.</span><span class="n">write</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1"># Make sure vim has been replaced with Vim</span>
</span><span class='line'>    <span class="n">vim</span><span class="o">.</span><span class="n">echo</span><span class="p">(</span><span class="s1">&#39;getline(&quot;.&quot;)&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">should</span> <span class="n">eq</span> <span class="s1">&#39;Vim is awesome. Vim Vim Vim&#39;</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>Now, you can run the tests by invoking RSpec:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>rspec
</span><span class='line'>
</span><span class='line'>.
</span><span class='line'>
</span><span class='line'>Finished in 0.64155 seconds
</span><span class='line'>1 example, 0 failures
</span></code></pre></td></tr></table></div></figure>


<p>Let&#8217;s write an additional spec that ensures our plugin is being activated only when editing makrdown files:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'>  <span class="n">it</span> <span class="s2">&quot;performs substitutions only in markdown files&quot;</span> <span class="k">do</span>
</span><span class='line'>    <span class="n">vim</span><span class="o">.</span><span class="n">edit!</span><span class="p">(</span><span class="s1">&#39;test.rb&#39;</span><span class="p">)</span>
</span><span class='line'>    <span class="n">vim</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="s1">&#39;vim.edit! &quot;foo&quot;&#39;</span><span class="p">)</span>
</span><span class='line'>    <span class="n">vim</span><span class="o">.</span><span class="n">write</span>
</span><span class='line'>    <span class="n">vim</span><span class="o">.</span><span class="n">echo</span><span class="p">(</span><span class="s1">&#39;getline(&quot;.&quot;)&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">should</span> <span class="n">eq</span> <span class="s1">&#39;vim.edit! &quot;foo&quot;&#39;</span>
</span><span class='line'>  <span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>If you run the specs again, you will see that we have 2 passing examples and 0 failures.</p>

<p>That&#8217;s it! Vimrunner makes controlling Vim instances a dead simple task. We wrote our first test in no time, and we have the confidence that our plugin is actually working as desired.</p>

<p>The entire source code is available on <a href="https://github.com/vesln/vim-sws">GitHub - vesln/vim-sws</a>.</p>

<h2>Conclusion</h2>

<p>In this post we covered how to spawn a Vim instance and control it programmatically in order verify that our plugin works correctly. However, there are many other situations in which you would find Vimrunner useful, testing is just one of them. I encourage you to take a look at the project and spend some time playing with it. I&#8217;m sure you&#8217;ll come up with great ideas. Cheers!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[HappyEdit - an HTML5 remake of Vim]]></title>
    <link href="http://www.vimninjas.com/2012/10/03/happyedit-an-html5-remake-of-vim/"/>
    <updated>2012-10-03T09:29:00+03:00</updated>
    <id>http://www.vimninjas.com/2012/10/03/happyedit-an-html5-remake-of-vim</id>
    <content type="html"><![CDATA[<p><img src="http://www.vimninjas.com/images/posts/happyedit/cover.png" alt="HappyEdit" /></p>

<p><em>This is a guest post from <a href="http://blog.perthulin.com/">Per Thulin</a>. Many know him from having worked at the crowdfunding startup <a href="http://flattr.com/">Flattr</a> and being co-founder of the online music service <a href="http://www.youtify.com/">Youtify</a>.</em></p>

<p><em>Twitter: <a href="http://twitter.com/pthulin">@pthulin</a> GitHub: <a href="https://github.com/pthulin">@pthulin</a></em></p>

<p>Hi, my name is Per Thulin and I am happy to be writing to a crowd full of handsome Vim users - my favorite kind of people!</p>

<p>I&#8217;ve been using Vim for longer than I can remember, but have started to feel jealous of my colleagues with their shiny new editors such as SublimeText and TextMate. Their syntax highlighting is so fast and they have tools for navigating file structures that just seem superior to anything that can be accomplished with Vim and it&#8217;s plugins.</p>

<p>So I&#8217;ve started a new project, an HTML5 remake of my good old Vim editor, using modern technologies such as HTML5. It&#8217;s called <a href="http://happyedit.se">HappyEdit</a> and is 100% <a href="https://github.com/pthulin/HappyEdit">open source</a> and based on the Ace project worked on by Cloud9, Mozilla and others.</p>

<!-- more -->


<p>I&#8217;ve got an initial version ready that already feels wonderful to use and that has replaced MacVim as my main text editor.</p>

<p><strong>Implemented features in HappyEdit:</strong></p>

<ul>
<li>Vim like INSERT/COMMAND/NORMAL modes, keybindings and search.</li>
<li>Beautiful command line with autocompletions for files and commands.</li>
<li>Tabbed interface.</li>
<li>Minimalistic window border design.</li>
<li>Blazingly fast syntax highlighting for 40+ languages.</li>
<li>CommandT-like way of opening files.</li>
<li>A remote mode, so that you can work on files that are on another computer.</li>
</ul>


<p><strong>Upcoming features:</strong></p>

<ul>
<li>A better way of searching multiple files, replacing vimgrep.</li>
<li>A settings panel exposing options that are hard to find in Vim.</li>
<li>Window splits.</li>
<li>Ability to drag tabs between windows.</li>
<li>Jump to definition &amp; symbol navigation.</li>
<li>Plugin system.</li>
</ul>


<p>This involves a lot of work and I would love to be able to work full time on this project. So, I&#8217;ve started a campaign over at <a href="http://www.indiegogo.com/happyedit?a=1061258">Indiegogo</a>.</p>

<p>Take a moment to check it out and also share it with your friends. Get perks, make a contribution, or simply follow updates. If enough of us get behind it, we can make HappyEdit happen.</p>

<p><a href="http://www.indiegogo.com/happyedit?a=1061258">http://www.indiegogo.com/happyedit</a></p>

<p>Thanks!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Compile Vim with Ruby & Python support on OS X]]></title>
    <link href="http://www.vimninjas.com/2012/09/21/vim-ruby-python/"/>
    <updated>2012-09-21T12:09:00+03:00</updated>
    <id>http://www.vimninjas.com/2012/09/21/vim-ruby-python</id>
    <content type="html"><![CDATA[<p><img src="http://www.vimninjas.com/images/posts/vim-ruby-python/cover.png" alt="Compile Vim with Ruby &amp; Python" /></p>

<p>Vim can be extended with Ruby and Python if it&#8217;s compiled with the +ruby and +python features. If you are using MacVim, you
already have them, so you can continue using it happily. But the terminal Vim
that comes with your OS X does not support them. Fortunately, we can fix that in
less than 5 minutes.</p>

<!-- more -->


<p>The process is similar to what we described in <a href="http://www.vimninjas.com/2012/08/30/fixing-the-macvim-cursor-bug-on-mbp-retina/">Fixing the MacVim Cursor Bug on MBP Retina</a>,
but this time it&#8217;s for the terminal Vim.</p>

<p>If you are a <a href="http://mxcl.github.com/homebrew/">Homebrew</a> user, you can install a new version of Vim by typing the
following commands in your terminal:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>brew install mercurial
</span><span class='line'><span class="nv">$ </span>brew install https://raw.github.com/gist/3760533/74dd7bf6647c927c782b1cd9ff99e22161e375e9/vim.rb
</span></code></pre></td></tr></table></div></figure>


<p>If you want different compile options, you can <a href="https://gist.github.com/3760533">fork the gist</a> and customize it as
you wish.</p>

<p>If you don&#8217;t use Homebrew, you can still compile it by your own. You need
mercurial in order to clone the Vim repository. After that, everything is quite straightforward:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span><span class="nb">cd</span> /tmp
</span><span class='line'><span class="nv">$ </span>hg clone https://vim.googlecode.com/hg/ vim
</span><span class='line'><span class="nv">$ </span><span class="nb">cd </span>vim
</span><span class='line'><span class="nv">$ </span>hg update -c 1e22adc6176e
</span><span class='line'><span class="nv">$ </span>./configure --prefix<span class="o">=</span>/usr/local <span class="se">\</span>
</span><span class='line'>              --enable-gui<span class="o">=</span>no <span class="se">\</span>
</span><span class='line'>              --without-x <span class="se">\</span>
</span><span class='line'>              --disable-nls <span class="se">\</span>
</span><span class='line'>              --enable-multibyte <span class="se">\</span>
</span><span class='line'>              --with-tlib<span class="o">=</span>ncurses <span class="se">\</span>
</span><span class='line'>              --enable-pythoninterp <span class="se">\</span>
</span><span class='line'>              --enable-rubyinterp <span class="se">\</span>
</span><span class='line'>              --with-ruby-command<span class="o">=</span>/usr/bin/ruby <span class="se">\</span>
</span><span class='line'>              --with-features<span class="o">=</span>huge
</span><span class='line'><span class="nv">$ </span>make
</span><span class='line'><span class="nv">$ </span>sudo make install
</span></code></pre></td></tr></table></div></figure>


<p>Please note that we are installing Vim in <code>/usr/local/bin</code>, so it has to be
included in your <code>PATH</code> before <code>/usr/bin</code>, where the old terminal Vim is located. You can easily accomplish this by adding
the following line in your <code>.bashrc</code> or <code>.zshrc</code>:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># .bashrc or .zshrc</span>
</span><span class='line'>
</span><span class='line'><span class="nb">export </span><span class="nv">PATH</span><span class="o">=</span>/usr/local/bin:<span class="nv">$PATH</span>
</span></code></pre></td></tr></table></div></figure>


<p>That&#8217;s it! Your Vim with Ruby &amp; Python support is ready for some action.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Replace in multiple files - the Vim way]]></title>
    <link href="http://www.vimninjas.com/2012/09/19/replace-multiple/"/>
    <updated>2012-09-19T14:05:00+03:00</updated>
    <id>http://www.vimninjas.com/2012/09/19/replace-multiple</id>
    <content type="html"><![CDATA[<p><img src="http://www.vimninjas.com/images/posts/replace-multiple/cover.png" alt="Search and Replace in multiple files" /></p>

<p>Replacing text in multiple files is really easy with Vim. However, it&#8217;s not quite
popular feature and a lot of people don&#8217;t know that such exists. In this post we
will show you a few tricks that will get the job done.</p>

<!-- more -->


<p>If you want to replace <code>_params</code> with <code>params</code> in the current buffer, you can do it by executing the following command:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="p">:</span>%<span class="k">s</span><span class="sr">/_params/</span>params/ge
</span></code></pre></td></tr></table></div></figure>


<p>However, if the substitution has to be made across all files with extension <code>.rb</code> in a directory, you will have to use <code>argdo</code>:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="p">:</span>args app<span class="sr">/controllers/</span>*.rb
</span><span class='line'><span class="p">:</span><span class="k">argdo</span> :%<span class="k">s</span><span class="sr">/_params/</span>params/ge <span class="p">|</span> <span class="k">update</span>
</span></code></pre></td></tr></table></div></figure>


<p>Also you can put the <code>c</code> flag, which will ask for confirmation before each change. Pretty neat, huh?</p>

<p>The limitation of <code>argdo</code> is that it won&#8217;t search the supplied directory recursively, but you can use the awesome <a href="http://www.vim.org/scripts/script.php?script_id=367">DirDo.vim</a> plugin to accomplish it:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="p">:</span>DDD app/controllers
</span><span class='line'><span class="p">:</span>DDP *.rb
</span><span class='line'><span class="p">:</span>DDO :%<span class="k">s</span><span class="sr">/_params/</span>params/ge <span class="p">|</span> <span class="k">update</span>
</span></code></pre></td></tr></table></div></figure>


<p>Finally, the unix tools <code>sed</code> and <code>awk</code> are always an option that you might consider handy.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[10 light vim color schemes that you should consider using]]></title>
    <link href="http://www.vimninjas.com/2012/09/14/10-light-colors/"/>
    <updated>2012-09-14T10:59:00+03:00</updated>
    <id>http://www.vimninjas.com/2012/09/14/10-light-colors</id>
    <content type="html"><![CDATA[<p><img src="http://www.vimninjas.com/images/posts/10light/cover.png" alt="cover" /></p>

<p>After presenting you &#8221;<a href="http://www.vimninjas.com/2012/08/26/10-vim-color-schemes-you-need-to-own/">10 Vim color schemes you need to own</a>&#8221;, we decided to
post a dedicated article with light color schemes. This post is inspired from the feedback that we
received from you. Most of the color schemes mentioned here are suggested by our awesome readers.
Thank you guys, you rock!</p>

<!-- more -->


<h2>1. pyte</h2>

<p><img src="http://www.vimninjas.com/images/posts/10light/pyte.png" alt="pyte" /></p>

<p><a href="http://www.vim.org/scripts/script.php?script_id=1492">pyte</a> is a light color scheme created by
Henning Hasemann. Its main colors are light grey, green and blue. Thanks to <a href="http://ryanflorence.com/">Ryan Florence</a> for
suggesting it.</p>

<h2>2. eclipse</h2>

<p><img src="http://www.vimninjas.com/images/posts/10light/eclipse.png" alt="eclipse" /></p>

<p>As you can easily guess, <a href="http://www.vim.org/scripts/script.php?script_id=1802">eclipse.vim</a> is based on the default colors of the Eclipse IDE.
If you have ever done Java development, it should look familiar to you. Let&#8217;s thank Juan Frias for creating it.</p>

<h2>3. summerfruit256</h2>

<p><img src="http://www.vimninjas.com/images/posts/10light/summerfruit256.png" alt="summerfruit256" /></p>

<p><a href="http://www.vim.org/scripts/script.php?script_id=2577">summerfruit256</a> is our personal number one. It&#8217;s really fresh and it helps you to focus more on the important stuff. The theme is the 256 color
version of Armin Ronacher&#8217;s summerfruit color scheme. It&#8217;s created by Martin Baeuml.</p>

<h2>4. AutumnLeaf</h2>

<p><img src="http://www.vimninjas.com/images/posts/10light/autumnleaf.png" alt="AutumnLeaf" /></p>

<p>The colors of a Finnish autumn morning captured and packed in a nice <a href="http://www.vim.org/scripts/script.php?script_id=1107">color scheme</a>, which is light orange/blue/green and doesn&#8217;t cause eye strain.
It&#8217;s handy for Ruby, C/C++, XHTML, CSS and even for Markdown.</p>

<h2>5. ironman</h2>

<p><img src="http://www.vimninjas.com/images/posts/10light/ironman.png" alt="ironman" /></p>

<p>Except the awesome name, <a href="http://www.vim.org/scripts/script.php?script_id=399">ironman</a> is a light color scheme that can become your primary weapon when attacking legacy code.
It&#8217;s all about comfort and productivity. We find it really good option for long coding sessions.</p>

<h2>6. nuvola</h2>

<p><img src="http://www.vimninjas.com/images/posts/10light/nuvola.png" alt="nuvola" /></p>

<p><a href="http://www.vim.org/scripts/script.php?script_id=719">nuvola</a> is inspired by the Gnome2 SVG theme &#8220;nuvola&#8221;. It looks really unixy. If you are
a Gnome fan, you should consider using it. It&#8217;s downloaded more than 2000 times and we are sure that it will gain even more popularity in the future.</p>

<h2>7. oceanlight</h2>

<p><img src="http://www.vimninjas.com/images/posts/10light/oceanlight.png" alt="oceanlight" /></p>

<p><a href="http://www.vim.org/scripts/script.php?script_id=1176">oceanlight</a> is a light pale blue and green color scheme originally based on oceandeep,
intended to be easy on the eyes and not burden you with contrast. Its maintainer is Håkan Wikström.</p>

<h2>8. simpleandfriendly</h2>

<p><img src="http://www.vimninjas.com/images/posts/10light/simpleandfriendly.png" alt="simpleandfriendly" /></p>

<p><a href="http://www.vim.org/scripts/script.php?script_id=792">simpleandfriendly</a> is really simple color scheme and that&#8217;s why people like it.
Thomas Schmall used very eye-friendly colors and put some optical emphasis on comments. It&#8217;s perfect for 256 terminals and GUI Vim.</p>

<h2>9. buttercream</h2>

<p><img src="http://www.vimninjas.com/images/posts/10light/buttercream.png" alt="buttercream" /></p>

<p>There are quite a few themes with yellow background. <a href="http://www.vim.org/scripts/script.php?script_id=881">buttercream</a> is probably one of the most popular out there. It&#8217;s downloaded more than
1700 times, mostly because it&#8217;s really amazing. Håkan Wikström did great job by balancing the colors used in it.</p>

<h2>10. solarized</h2>

<p><img src="http://www.vimninjas.com/images/posts/10light/solarized.png" alt="solarized" /></p>

<p><a href="https://github.com/altercation/vim-colors-solarized">Solarized</a> needs no introduction. Its dark version was featured in our previous post, but the light one looks
stunning as well. It&#8217;s the primary choice of many developers. Give it a try and you won&#8217;t regret it.</p>

<h2>But wait, only 10?</h2>

<p>Let&#8217;s expand our collection even further. What&#8217;s your favourite light color scheme?
Post it in the comments. Also, if you want to submit a guest post about your favourite
theme, just contact us and we will make it happen.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Code substitution done right - Switch.vim]]></title>
    <link href="http://www.vimninjas.com/2012/09/12/switch/"/>
    <updated>2012-09-12T10:26:00+03:00</updated>
    <id>http://www.vimninjas.com/2012/09/12/switch</id>
    <content type="html"><![CDATA[<p><img src="http://www.vimninjas.com/images/posts/switch/cover.png" alt="Switch.vim" /></p>

<p><a href="https://github.com/AndrewRadev/switch.vim">Switch.vim</a> by <a href="http://andrewradev.com/">Andrew Radev</a>
is a highly customizable plugin that will help you do substitutions faster than ever.</p>

<!-- more -->


<h2>Usage</h2>

<p>The plugin is simple to use, since it has one main entry point - the command <code>:Switch</code>. It&#8217;s highly
encouraging to map it to a key, as the author suggests in the documentation:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="nb">nnoremap</span> <span class="p">-</span> :Switch<span class="p">&lt;</span><span class="k">cr</span><span class="p">&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>It comes with support for Ruby, PHP, Eruby, C and CoffeeScript. However, you can easily
add your own switch definitions and make it even more powerful.</p>

<p>You can switch between the following definitions by invoking the <code>:Switch</code> command. Here are some of the built-ins:</p>

<ul>
<li>Boolean conditions:</li>
</ul>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'>foo &amp;&amp; <span class="k">bar</span>
</span><span class='line'>foo <span class="p">||</span> <span class="k">bar</span>
</span></code></pre></td></tr></table></div></figure>


<ul>
<li>Boolean constants:</li>
</ul>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'>flag <span class="p">=</span> true
</span><span class='line'>flag <span class="p">=</span> false
</span><span class='line'>
</span><span class='line'>flag <span class="p">=</span> True
</span><span class='line'>flag <span class="p">=</span> False
</span></code></pre></td></tr></table></div></figure>


<ul>
<li>Hash style:</li>
</ul>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">foo</span> <span class="o">=</span> <span class="p">{</span> <span class="ss">:one</span> <span class="o">=&gt;</span> <span class="s1">&#39;two&#39;</span> <span class="p">}</span>
</span><span class='line'><span class="n">foo</span> <span class="o">=</span> <span class="p">{</span> <span class="n">one</span><span class="p">:</span> <span class="s1">&#39;two&#39;</span> <span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<ul>
<li>If-clauses:</li>
</ul>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">if</span> <span class="n">predicate?</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s1">&#39;Hello, World!&#39;</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="k">if</span> <span class="kp">true</span> <span class="ow">or</span> <span class="p">(</span><span class="n">predicate?</span><span class="p">)</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s1">&#39;Hello, World!&#39;</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="k">if</span> <span class="kp">false</span> <span class="ow">and</span> <span class="p">(</span><span class="n">predicate?</span><span class="p">)</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s1">&#39;Hello, World!&#39;</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<ul>
<li>Rspec should/should_not:</li>
</ul>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="mi">1</span><span class="o">.</span><span class="n">should</span> <span class="n">eq</span> <span class="mi">1</span>
</span><span class='line'><span class="mi">1</span><span class="o">.</span><span class="n">should_not</span> <span class="n">eq</span> <span class="mi">1</span>
</span></code></pre></td></tr></table></div></figure>


<ul>
<li>String style:</li>
</ul>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">foo</span> <span class="o">=</span> <span class="s1">&#39;bar&#39;</span>
</span><span class='line'><span class="n">foo</span> <span class="o">=</span> <span class="s2">&quot;baz&quot;</span>
</span><span class='line'><span class="n">foo</span> <span class="o">=</span> <span class="ss">:baz</span>
</span></code></pre></td></tr></table></div></figure>


<ul>
<li>Coffeescript arrows</li>
</ul>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='coffeescript'><span class='line'><span class="nx">functionCall</span> <span class="nf">(foo) -&gt;</span>
</span><span class='line'><span class="nx">functionCall</span> <span class="p">(</span><span class="nx">foo</span><span class="p">)</span> <span class="o">=&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<h2>Customizations</h2>

<p>Adding your own definitions is as easy as:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="k">let</span> <span class="k">g</span>:switch_definitions <span class="p">=</span>
</span><span class='line'>    \ [
</span><span class='line'>    \   [<span class="s1">&#39;if&#39;</span><span class="p">,</span> <span class="s1">&#39;unless&#39;</span>]
</span><span class='line'>    \ ]
</span></code></pre></td></tr></table></div></figure>


<p>Now you can easily switch between <code>if</code> and <code>unless</code>:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">if</span> <span class="n">foo</span>
</span><span class='line'>  <span class="c1"># Do something</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="k">unless</span> <span class="n">foo</span>
</span><span class='line'>  <span class="c1"># Do something</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>View the documentation for more advanced examples.</p>

<h2>Screencast</h2>

<p>You can check out this awesome screencast created by Andrew to see the plugin in action:</p>

<iframe width="560" height="420" src="http://www.youtube.com/embed/zIOOLZJb87U" frameborder="0" allowfullscreen></iframe>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Optimize your TDD workflow by writing Vim plugins]]></title>
    <link href="http://www.vimninjas.com/2012/09/06/related-file/"/>
    <updated>2012-09-06T08:20:00+03:00</updated>
    <id>http://www.vimninjas.com/2012/09/06/related-file</id>
    <content type="html"><![CDATA[<p><img src="http://www.vimninjas.com/images/posts/related-file/cover.png" alt="TDD and Vim" /></p>

<p>We often spend time optimizing our workflow. We learn new technologies, new patterns and constantly improve ourselves. But we often forget about our existing tools and how powerful they are. Vim is one of those tools.</p>

<p>In this article we are going to build a simple Vim plugin, which creates related files. The point is not to teach you some Vim script, but to remind you that your Vim is there and it takes only a few minutes to make it better by writing a few lines of code.</p>

<!-- more -->


<h2>The idea</h2>

<p>The idea of our brand new Vim plugin is to help us with our TDD workflow. Every time when you create a new file, instead of creating the test file manually, Vim will magically add it for you. This approach is heavily inspired from the <a href="https://github.com/tpope/vim-rails">vim-rails plugin</a>, which gives you a simple <code>:A</code> command that opens the related test file.</p>

<h2>Before we begin</h2>

<p>Since we are Rails developers and we use Rspec a lot, we will create our plugin with them in mind. But don&#8217;t worry, you can use it for your favourite language/framework and testing library with just a few tweaks here and there.</p>

<p>Here is a typical Ruby on Rails structure. We need to analyze it before starting with our code:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>app/models/user.rb
</span><span class='line'>app/controllers/users_controller.rb
</span><span class='line'>...
</span><span class='line'>spec/models/user_spec.rb
</span><span class='line'>spec/controllers/users_controller_spec.rb
</span><span class='line'>...</span></code></pre></td></tr></table></div></figure>


<p>So, if we replace &#8220;app&#8221; with &#8220;spec&#8221; and &#8220;.rb&#8221; with &#8220;_spec.rb&#8221;, then we will get the path of the test file. Hm, that looks easy. But we also have to keep in mind that the file might be already created.</p>

<h2>Create related file</h2>

<p>Create a new file in your <code>~/.vim/plugin/</code> directory with the name <code>related.vim</code>.</p>

<p>All we need to do is grab the filename, figure out if it&#8217;s a test file or not and, depending on the result, open/create the associated file.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="c">&quot; Open/Create related spec/file</span>
</span><span class='line'><span class="k">function</span><span class="p">!</span> <span class="k">s</span>:CreateRelated<span class="p">()</span>
</span><span class='line'>  <span class="k">let</span> related <span class="p">=</span> <span class="k">s</span>:GetRelatedFile<span class="p">(</span>expand<span class="p">(</span><span class="s1">&#39;%&#39;</span><span class="p">))</span>
</span><span class='line'>  <span class="k">call</span> <span class="k">s</span>:Open<span class="p">(</span>related<span class="p">)</span>
</span><span class='line'><span class="k">endfunction</span>
</span><span class='line'>
</span><span class='line'><span class="c">&quot; Return the related filename</span>
</span><span class='line'><span class="k">function</span><span class="p">!</span> <span class="k">s</span>:GetRelatedFile<span class="p">(</span><span class="k">file</span><span class="p">)</span>
</span><span class='line'>  <span class="k">if</span> <span class="k">match</span><span class="p">(</span><span class="k">a</span>:<span class="k">file</span><span class="p">,</span> <span class="s1">&#39;_spec\.rb$&#39;</span><span class="p">)</span> <span class="p">!=</span> <span class="m">-1</span>
</span><span class='line'>    <span class="k">return</span> substitute<span class="p">(</span>substitute<span class="p">(</span><span class="k">a</span>:<span class="k">file</span><span class="p">,</span> <span class="s2">&quot;_spec.rb$&quot;</span><span class="p">,</span> <span class="s2">&quot;.rb&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">),</span> <span class="s1">&#39;^spec/&#39;</span><span class="p">,</span> <span class="s1">&#39;app/&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
</span><span class='line'>  <span class="k">else</span>
</span><span class='line'>    <span class="k">return</span> substitute<span class="p">(</span>substitute<span class="p">(</span><span class="k">a</span>:<span class="k">file</span><span class="p">,</span> <span class="s2">&quot;.rb$&quot;</span><span class="p">,</span> <span class="s2">&quot;_spec.rb&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">),</span> <span class="s1">&#39;^app/&#39;</span><span class="p">,</span> <span class="s1">&#39;spec/&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
</span><span class='line'>  <span class="k">endif</span>
</span><span class='line'><span class="k">endfunction</span>
</span><span class='line'>
</span><span class='line'><span class="c">&quot; Open the related file in a vsplit</span>
</span><span class='line'><span class="k">function</span><span class="p">!</span> <span class="k">s</span>:Open<span class="p">(</span><span class="k">file</span><span class="p">)</span>
</span><span class='line'>  exec<span class="p">(</span><span class="s1">&#39;vsplit &#39;</span> . <span class="k">a</span>:<span class="k">file</span><span class="p">)</span>
</span><span class='line'><span class="k">endfunction</span>
</span><span class='line'>
</span><span class='line'><span class="c">&quot; Register a new command `AC` for open/create a related file</span>
</span><span class='line'>command<span class="p">!</span> AC :<span class="k">call</span> <span class="p">&lt;</span>SID<span class="p">&gt;</span>CreateRelated<span class="p">()</span>
</span></code></pre></td></tr></table></div></figure>


<p>You can notice that the new file is opened in a vertical split. This is our preferred workflow, but you can change it by replacing <code>vsplit</code> with <code>split</code> etc.</p>

<h2>What&#8217;s next?</h2>

<p>It feels good, doesn&#8217;t it? We are saving ourselves a few second each time when we create a new test file. We&#8217;ve learned some Vimscript, as well. If you want to dig deeper, we have some useful resources for you:</p>

<ul>
<li><a href="http://learnvimscriptthehardway.stevelosh.com/">http://learnvimscriptthehardway.stevelosh.com/</a></li>
<li><a href="http://www.packtpub.com/hacking-vim-cookbook-get-most-out-latest-vim-editor/book">http://www.packtpub.com/hacking-vim-cookbook-get-most-out-latest-vim-editor/book</a></li>
<li><a href="http://pragprog.com/book/dnvim/practical-vim">http://pragprog.com/book/dnvim/practical-vim</a></li>
</ul>


<h2>Conclusion</h2>

<p>Hacking Vim scripts is easy and totally worth your time. Don&#8217;t forget - Vim is probably your greatest tool. It won&#8217;t let you down. Spend some time with your Vim files once in a while. Do some crazy experiments, solve some impossible tasks. Don&#8217;t worry if it feels like it&#8217;s out of your comfort zone. You will become better in time.</p>

<p>What&#8217;s your favorite Vim hack? How often do you update your vimrc? Have you learned Vimscript already? What&#8217;s your best advice when it comes to writing plugins? Share it with us.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[5 plugins you should put in your vimrc]]></title>
    <link href="http://www.vimninjas.com/2012/09/03/5-plugins-you-should-put-in-your-vimrc/"/>
    <updated>2012-09-03T08:44:00+03:00</updated>
    <id>http://www.vimninjas.com/2012/09/03/5-plugins-you-should-put-in-your-vimrc</id>
    <content type="html"><![CDATA[<p><img src="http://www.vimninjas.com/images/posts/5-plugins/cover.png" alt="5 vim plugins" /></p>

<p><a href="http://www.flickr.com/photos/juniorvelo/4490511204/">Photo by Velo Steve</a></p>

<p>There are more than 4000 Vim scripts out there. This is one of the reasons why Vim is so awesome. However, if you are starting with Vim, you might wonder from where to begin. In this post we are going to talk about 5 plugins that can be found in almost any vimrc.</p>

<!-- more -->


<h2>Surround</h2>

<p><img src="http://www.vimninjas.com/images/posts/5-plugins/surround.png" alt="Surround" /></p>

<p><a href="https://github.com/tpope/vim-surround">Surround</a> provides mappings to easily delete, change and add surroundings in pairs. It&#8217;s created by Tim Pope, and it&#8217;s starred more than 800 times on GitHub.</p>

<p>The best way to explain it is to show some examples:</p>

<p>Go inside the following text and press cs&#8221;&#8217;:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="s2">&quot;Hello world!&quot;</span>
</span></code></pre></td></tr></table></div></figure>


<p>It changed the double quotes to single. Cool, isn&#8217;t it? You can also remove them by pressing <code>ds"</code>.</p>

<p>This plugin is really powerful and it can be extremely useful, check <a href="https://github.com/tpope/vim-surround/blob/master/doc/surround.txt">the documentation</a> for more examples.</p>

<h2>Command-T</h2>

<p><img src="http://www.vimninjas.com/images/posts/5-plugins/command-t.png" alt="Command-T" /></p>

<p><a href="https://github.com/wincent/Command-T">Command-T</a> provides a fast mechanism for opening files and buffers with a minimal effort. Its name comes from the &#8220;Go to File&#8221; functionality in TextMate, bound to <code>cmd + t</code>.</p>

<p>Command-T is really advanced and it orders the files in your working directory, when searching, by an algorithm which knows that characters in certain locations should have more weight.</p>

<p>You can check this awesome <a href="https://wincent.com/products/command-t">screencast</a> in order to view it in action.</p>

<h2>snipMate</h2>

<p><img src="http://www.vimninjas.com/images/posts/5-plugins/snipmate.png" alt="snipmate" /></p>

<p><a href="https://github.com/msanders/snipmate.vim/">snipMate</a> is a plugin created by Michael Sanders. It&#8217;s an implementation of TextMate&#8217;s snippets features in Vim. A snippet is a often-typed text that you can easily insert by typing a word + tab. Here is an example:</p>

<p>If you are writing JavaScript and you type &#8220;for<tab>&#8221; in insert mode, it will expand a typical <code>for</code> loop:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">Things</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>  <span class="nx">Things</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span>
</span><span class='line'><span class="p">};</span>
</span></code></pre></td></tr></table></div></figure>


<p>By pressing tab, you can switch between the highlighted items and change them.</p>

<p>snipMate comes with convenient snippets for C, HTML, JavaScript, PHP, Ruby, zsh, Vim and others. Apart from that, you can define your own snippets and make yourself even more productive.</p>

<h2>Syntastic</h2>

<p><img src="http://www.vimninjas.com/images/posts/5-plugins/syntastic.png" alt="Syntastic" /></p>

<p><a href="https://github.com/scrooloose/syntastic">Syntastic</a> is a syntax checking plugin that runs files through external syntax checkers and displays any resulting errors.</p>

<p>There is a support for huge amount of languages, including C, CoffeeScript, CSS, Cucumber, Erlang, Go, Haml, Haskell, HTML, JavaScript, PHP, Python, Ruby.</p>

<h2>Buffer Explorer</h2>

<p><img src="http://www.vimninjas.com/images/posts/5-plugins/buffexplorer.png" alt="Bufexplorer" /></p>

<p><a href="http://www.vim.org/scripts/script.php?script_id=42">Bufexplorer</a> is a plugin designed to optimise the browsing of Vim buffers. When you invoke it, it renders a sorted list of all buffers that are currently open. After that, you can easily sort, open or delete any of them.</p>

<p>You can open Bufexplorer by using one of the default public interfaces:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="o">&lt;</span><span class="nx">Leader</span><span class="o">&gt;</span><span class="nx">be</span>  <span class="o">-</span> <span class="nx">Opens</span> <span class="nx">BE</span><span class="p">.</span>
</span><span class='line'><span class="o">&lt;</span><span class="nx">Leader</span><span class="o">&gt;</span><span class="nx">bs</span>  <span class="o">-</span> <span class="nx">Opens</span> <span class="nx">horizontally</span> <span class="nb">window</span> <span class="nx">BE</span><span class="p">.</span>
</span><span class='line'><span class="o">&lt;</span><span class="nx">Leader</span><span class="o">&gt;</span><span class="nx">bv</span>  <span class="o">-</span> <span class="nx">Opens</span> <span class="nx">vertically</span> <span class="nb">window</span> <span class="nx">BE</span><span class="p">.</span>
</span></code></pre></td></tr></table></div></figure>


<p>What&#8217;s your favourite Vim plugin? What are the most useful plugins that you know? Is there a plugin that you consider as really useful, but not quite popular? Let us know in the comments.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Gain productivity by having different vim settings for every project]]></title>
    <link href="http://www.vimninjas.com/2012/08/30/local-vimrc/"/>
    <updated>2012-08-30T19:58:00+03:00</updated>
    <id>http://www.vimninjas.com/2012/08/30/local-vimrc</id>
    <content type="html"><![CDATA[<p><img src="http://www.vimninjas.com/images/posts/local-vimrc/cover.png" alt="Local .vimrc" /></p>

<p>Sometimes you just want to have vim configurations per project basis. Imagine how awesome it is to
fire up vim with a different color scheme for each one of your projects. You might want to include
special plugins for the Node.js project you are hacking on lately. Fortunately, this is extremely
easy to accomplish.</p>

<p>Create a file called &#8220;vimrc-local.vim&#8221; in the <code>~/.vim/plugin/</code> directory. After that, put the following
5 lines of code in it:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="c">&quot; Do we have local vimrc?</span>
</span><span class='line'><span class="k">if</span> filereadable<span class="p">(</span><span class="s1">&#39;.vimrc.local&#39;</span><span class="p">)</span>
</span><span class='line'><span class="c">  &quot; If so, go ahead and load it.</span>
</span><span class='line'>  source .vimrc.local
</span><span class='line'><span class="k">endif</span>
</span></code></pre></td></tr></table></div></figure>


<p>Now you can put local vimrc file in any directory of your computer and vim will automatically
load it for you. Don&#8217;t forget that you have to name the config file &#8220;.vimrc.local&#8221;. If you prefer
a different name, you can replace <code>.vimrc.local</code> with your desired name in the script we just wrote.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span><span class="nb">cd </span>path/to/project
</span><span class='line'><span class="nv">$ </span>ls .vimrc.local
</span><span class='line'><span class="nv">$ </span>mvim . <span class="c"># or vim, etc.</span>
</span></code></pre></td></tr></table></div></figure>


<p>You might be curious what the local vimrc of Vim Ninjas looks like. Here it is:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="c">&quot; The awesome vividchalk color scheme</span>
</span><span class='line'><span class="k">colorscheme</span> vividchalk
</span><span class='line'>
</span><span class='line'><span class="c">&quot; Check spelling</span>
</span><span class='line'><span class="k">set</span> <span class="k">spell</span>
</span><span class='line'>
</span><span class='line'><span class="c">&quot; Monaco 14</span>
</span><span class='line'><span class="k">set</span> <span class="nb">guifont</span><span class="p">=</span>Monaco:h14
</span></code></pre></td></tr></table></div></figure>


<p>Your editor might look and feel completely different depending on your current focus. Just a few lines
of code and you are there. How cool is that?</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Fixing the MacVim cursor bug on MBP Retina]]></title>
    <link href="http://www.vimninjas.com/2012/08/30/fixing-the-macvim-cursor-bug-on-mbp-retina/"/>
    <updated>2012-08-30T15:27:00+03:00</updated>
    <id>http://www.vimninjas.com/2012/08/30/fixing-the-macvim-cursor-bug-on-mbp-retina</id>
    <content type="html"><![CDATA[<p><img src="http://www.vimninjas.com/images/posts/mbpr-cursor/cover.png" alt="MacBook Pro Retina" /></p>

<p><a href="http://www.flickr.com/photos/sicnarf/7478589392/">Photo by Francis Bourgouin</a></p>

<p>When we installed MacVim on the new MacBook Pro with Retina display, we noticed that the cursor leaves scrapes behind itself. After a little investigation, we found that someone
already fired up a bug in the <a href="http://code.google.com/p/macvim/issues/detail?id=419">MacVim issue tracker</a>. <a href="http://b4winckler.wordpress.com/">Björn Winckler </a> reacted almost
immediately and the bug is now fixed. However, you need to install the latest HEAD of the <a href="https://github.com/b4winckler/macvim">MacVim git repository</a> in order to have a version
with the patch.</p>

<!-- more -->


<h2>Homebrew</h2>

<p><a href="http://mxcl.github.com/homebrew/">Homebrew</a> provides really convenient command to install and compile the MacVim master branch.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>brew install macvim --HEAD
</span></code></pre></td></tr></table></div></figure>


<p>As simple as that. You are good to go.</p>

<p>However, if you are not a Homebrew user, you have to compile MacVim manually.</p>

<h2>Compiling MacVim</h2>

<p>First, you have to clone the git repo:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span><span class="nb">cd</span> /tmp
</span><span class='line'><span class="nv">$ </span>git clone git://github.com/b4winckler/macvim.git
</span></code></pre></td></tr></table></div></figure>


<p>After that, you have to <code>configure</code> and <code>make</code> the project:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span><span class="nb">cd </span>macvim/src/
</span><span class='line'><span class="nv">$ </span>./configure --with-features<span class="o">=</span>huge <span class="se">\</span>
</span><span class='line'>                  --enable-rubyinterp <span class="se">\</span>
</span><span class='line'>                  --enable-pythoninterp <span class="se">\</span>
</span><span class='line'>                  --enable-perlinterp <span class="se">\</span>
</span><span class='line'>                  --enable-cscope
</span><span class='line'><span class="nv">$ </span>make
</span></code></pre></td></tr></table></div></figure>


<p>Voila!</p>

<p>In order to test if everything works fine, you have to start the application by typing:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>open MacVim/build/Release/MacVim.app
</span></code></pre></td></tr></table></div></figure>


<p>If everything looks good, you can open <code>MacVim/build/Release</code> and drag the MacVim icon into your <code>Applications</code> folder.</p>

<h2>Conclusion</h2>

<p>Besides fixed cursor bug, you will get the latest state of the MacVim project, including performance improvements, fixed bugs, etc.
If you find any problems, do not hesitate to open a new issue in the <a href="http://code.google.com/p/macvim/issues/list">MacVim issue tracker</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Vim for Rubyists part 1]]></title>
    <link href="http://www.vimninjas.com/2012/08/28/vim-for-rubyists-part-1/"/>
    <updated>2012-08-28T10:38:00+03:00</updated>
    <id>http://www.vimninjas.com/2012/08/28/vim-for-rubyists-part-1</id>
    <content type="html"><![CDATA[<p><img src="http://www.vimninjas.com/images/posts/vim-rubyists/cover.png" alt="Ruby and Vim" />
<a href="http://www.flickr.com/photos/jarkko/524502392/">Photo by supervillain</a></p>

<p>It is really exciting to be a Rubyist lately. We have our amazing tools (rake, rspec, Cucumber, Rails etc.),
we write object-oriented code, that is easy to maintain and flexible when it comes to adding new features, and changing
domain logic. We have amazing hosting support from <a href="http://heroku.com">Heroku</a>, <a href="http://engineyard.com">Engine Yard</a> and <a href="http://www.rackspace.com/">Rackspace</a>.
And last, but not least, powerful monitoring tools like <a href="http://newrelic.com/">New Relic</a> are ready to tell us when there are issues in our applications. But do we have the
perfect editor? A lot of people are still using TextMate, some of them started the journey of Sublime Text 2 and others
made different choices (Emacs, RubyMine, TextMate 2 etc). And how about Vim? Do we have healthy community of Rubyists in
the Vim world? Is it worth giving it a try? Let&#8217;s find out.</p>

<!-- more -->


<h2>Rubyists using Vim</h2>

<p>Big percentage of the Rubyists are actually using Vim. Here are some of the most popular Vim evangelists out there:</p>

<p><strong>Gary Bernhardt</strong> - Gary is the creator of <a href="destroyallsoftware.com">Destroy all Software</a>. Watching him in action with Vim is really inspirational.
Subscribe to his screencasts and you will find out what we are talking about. You can learn a lot of useful Vim tricks by watching him write Ruby code.</p>

<ul>
<li>Twitter: <a href="http://twitter.com/garybernhardt">@garybernhardt</a></li>
<li>Vimfiles: <a href="https://github.com/garybernhardt/dotfiles">GitHub</a></li>
</ul>


<p><strong>Aaron Patterson (tenderlove)</strong> - Tenderlove is a Ruby and Rails core team member. He is super positive person,
spending a lot of his time making Rails and Ruby faster. So, thank you for that Aaron! Also, it&#8217;s a well-known fact, that he
prefers Vim over other editors. You can watch him using Vim in this <a href="https://peepcode.com/products/play-by-play-tenderlove-ruby-on-rails">PeepCode Play by Play episode</a>.</p>

<ul>
<li>Twitter: <a href="https://twitter.com/tenderlove">@tenderlove</a></li>
<li>Vimfiles: <a href="https://github.com/tenderlove/dot_vim">GitHub</a></li>
</ul>


<p><strong>Mislav Marohnić</strong> - Mislav is a software craftsman from Croatia. He is contributing to Zepto and Rails among others.
He wrote the famous <a href="http://mislav.uniqpath.com/2011/12/vim-revisited/">&#8220;Vim: revisited&#8221;</a> blog post, that inspired many people to start using Vim.</p>

<ul>
<li>Twitter: <a href="https://twitter.com/mislav">@mislav</a></li>
<li>Dotfiles: <a href="https://github.com/mislav/vimfiles">GitHub</a></li>
</ul>


<p>(Your name here? Are you a Rubyist using Vim? Send us your short introduction + links to your
twitter account and dot files and we will feature you in the post)</p>

<h2>Vim plugins for Ruby development</h2>

<h3>Vim Ruby</h3>

<p><a href="https://github.com/vim-ruby/vim-ruby">Vim Ruby</a> is probably the most popular Vim plugin for Ruby development. It can be found in pretty much every
vimrc owned by a Rubyist. It comes with mappings that make editing Ruby code much easier.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'>imap <span class="p">&lt;</span>S<span class="p">-</span>CR<span class="p">&gt;</span> <span class="p">&lt;</span>CR<span class="p">&gt;&lt;</span>CR<span class="p">&gt;</span><span class="k">end</span><span class="p">&lt;</span>Esc<span class="p">&gt;-</span><span class="k">cc</span>
</span></code></pre></td></tr></table></div></figure>


<p>This enables:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">if</span> <span class="nb">name</span> <span class="o">==</span> <span class="s2">&quot;John&quot;</span><span class="o">[&lt;--</span><span class="n">cursor</span><span class="o">]</span>
</span></code></pre></td></tr></table></div></figure>


<p>And when you press shift + enter:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">if</span> <span class="nb">name</span> <span class="o">==</span> <span class="s2">&quot;John&quot;</span>
</span><span class='line'>  <span class="o">[&lt;--</span><span class="n">cursor</span><span class="o">]</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>(Note: you can accomplish the same behaviour with <a href="https://github.com/tpope/vim-endwise">endwise</a> even without pressing shift).</p>

<p>Files with a filename extension of <code>.rb</code> or a ruby shebang line (<code>#!/usr/bin/ruby</code>) will be set to
filetype &#8220;ruby&#8221;. It brings mappings, options, matchit configuration etc.</p>

<p>If Vim Ruby is not in your Vim configurations you should definitely consider including it.</p>

<h3>Vim Rails</h3>

<p>Oh, Rails! Yes! <a href="http://tpo.pe/">Tim Pope</a> did an amazing job with <a href="https://github.com/tpope/vim-rails">Vim Rails</a>. It&#8217;s probably the most useful plugin we&#8217;ve ever used.
If you are a Rails developer, you will get a lot benefits just by installing it. Here are some useful examples:</p>

<h4>Easy navigation of the Rails directory structure</h4>

<p>You can easily jump to alternative files, for example to specs from production code, by typing
<code>:A</code> or <code>:AV</code> if you prefer to open it in a split window. Also, if you want to jump
from a controller action to the view file or vice versa, you can press <code>:R</code>.
Navigation between models, controllers and views is getting even easier with the following
commands: <code>:Rcontroller controller-name</code>, <code>:Rmodel model-name</code> etc.</p>

<h4>Enhanced syntax highlighting</h4>

<p>The plugin adds syntax highlighting for <code>has_and_belongs_to_many</code>, <code>has_many</code> etc. Better completion is
provided as well.</p>

<h4>Interfaces to rake &amp; Rails scripts</h4>

<p>You can use <code>:Rake</code> to run the current spec or feature. <code>:Rscript</code> is available for convenient
execution of scripts without leaving your favourite editor.</p>

<h4>Partial extraction &amp; migration inversion</h4>

<p><code>:Rextract file</code> can extract the current visual selection to <code>file</code> and replace it with <code>render partial: 'file'</code>.</p>

<h3>Ruby Refactoring</h3>

<p><a href="https://github.com/ecomba/vim-ruby-refactoring">Ruby Refactoring</a> is a plugin written by <a href="http://www.ecomba.org/">Enrique Comba Riepenhausen</a> and inspired by
some Ruby refactoring patterns that Gary Bernhardt presented in the Software Craftsmanship User Group UK.</p>

<p>You can easily add new parameters, inline temporary variables, extract constants and more. Here is the
full list of supported commands:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="ss">:RInlineTemp</span>             <span class="o">-</span> <span class="no">Inline</span> <span class="no">Temp</span>
</span><span class='line'><span class="ss">:RConvertPostConditional</span> <span class="o">-</span> <span class="no">Convert</span> <span class="no">Post</span> <span class="no">Conditional</span>
</span><span class='line'><span class="ss">:RExtractConstant</span>        <span class="o">-</span> <span class="no">Extract</span> <span class="no">Constant</span>
</span><span class='line'><span class="ss">:RExtractLet</span>             <span class="o">-</span> <span class="no">Extract</span> <span class="n">to</span> <span class="no">Let</span> <span class="p">(</span><span class="no">Rspec</span><span class="p">)</span>
</span><span class='line'><span class="ss">:RExtractLocalVariable</span>   <span class="o">-</span> <span class="no">Extract</span> <span class="no">Local</span> <span class="no">Variable</span>
</span><span class='line'><span class="ss">:RRenameLocalVariable</span>    <span class="o">-</span> <span class="no">Rename</span> <span class="no">Local</span> <span class="no">Variable</span>
</span><span class='line'><span class="ss">:RRenameInstanceVariable</span> <span class="o">-</span> <span class="no">Rename</span> <span class="no">Instance</span> <span class="no">Variable</span>
</span><span class='line'><span class="ss">:RExtractMethod</span>          <span class="o">-</span> <span class="no">Extract</span> <span class="no">Method</span>
</span></code></pre></td></tr></table></div></figure>


<p>For most of the commands you will need to install <a href="http://www.vim.org/scripts/script.php?script_id=39">matchit.vim</a> as well.</p>

<h3>Vim Cucumber</h3>

<p>Who doesn&#8217;t use Cucumber these days? We spend a lot of time writing acceptance tests,
so we need an environment that is going to help us to focus and refactor them better.</p>

<p><a href="https://github.com/tpope/vim-cucumber">Vim Cucumber</a> provides syntax highlighting, indenting, and a filetype detection for Cucumber.
You can use <code>CTRL-]</code> on a step to jump to its Ruby definition or, if you prefer splits,
you can use <code>CTRL-W-]</code>, like we do. Pretty useful, right?</p>

<h3>Vim Haml/Slim/Sass</h3>

<p>As Ruby developers we always use the latest and the greatest. It&#8217;s all about writing
beautiful code that is easy to maintain, isn&#8217;t it? That&#8217;s why we use Haml, Slim and
Sass. But Haml without syntax highlighting isn&#8217;t really useful. Fortunately, there are
a few plugins that will help you using your favourite frontend tools:</p>

<ul>
<li><a href="https://github.com/tpope/vim-haml">vim-haml</a> - runtime files for Haml and Sass.</li>
<li><a href="https://github.com/bbommarito/vim-slim">vim-slim</a> - similar to vim-haml, but for Slim.</li>
<li><a href="https://github.com/groenewege/vim-less">vim-less</a> - Less highlighting, indenting and autocompletion.</li>
</ul>


<h3>Janus</h3>

<p>If you are just starting with Vim, coming from TextMate or other editor, you can give <a href="https://github.com/carlhuda/janus">Janus</a> a shot.
It&#8217;s a distribution of plugins and mappings for Vim, Gvim and MacVim. It&#8217;s bundled with a lot of useful tools for
Ruby development and designed to reduce the learning curve of Vim. Apart from that, the community behind it did an amazing job
by making it extendable, so you can include your own configurations and plugins with no effort. Gundo, ctrlp, easymotion,
supertab, surround are just a few examples that come with Janus.</p>

<h3>And even more</h3>

<p>Apart from the plugins and the resources mentioned in the article, here is a list of
some useful links to resources, that will make you even more productive Rubyist:</p>

<ul>
<li><a href="https://github.com/tpope/vim-endwise">endwise</a> - adds <code>end</code> after <code>if</code>, <code>do</code>, <code>def</code> and several other keywords.</li>
<li><a href="https://github.com/msanders/snipmate.vim">snipmate</a> - TextMate like snippets for Vim</li>
<li><a href="https://github.com/tpope/vim-rake">vim-rake</a> - With rake.vim, you can use all those parts of rails.vim that you wish you could use on your other Ruby projects</li>
<li><a href="https://github.com/tpope/vim-bundler">vim-bundler</a> - This is a lightweight bag of Vim goodies for Bundler</li>
<li><a href="http://justinram.wordpress.com/2010/12/30/vim-ruby-refactoring-series/">Vim refactoring series</a> - Introduction to vim refactoring.</li>
<li><a href="http://biodegradablegeek.com/2007/12/using-vim-as-a-complete-ruby-on-rails-ide/">Using Vim as a Complete Ruby on Rails IDE</a> - Vim for Ruby.</li>
<li><a href="http://oldwiki.rubyonrails.org/rails/pages/HowtoUseVimWithRails">How to use Vim with Rails</a> - Cool post about Vim and Rails.</li>
<li><a href="http://arjanvandergaag.nl/blog/compiling-vim-with-ruby-support.html">Compiling Vim with Ruby support</a> - How to compile Vim with Ruby support.</li>
<li><a href="http://www.cuberick.com/2008/10/ruby-autocomplete-in-vim.html">Ruby autocomplete</a> - Autocompletion for Ruby in Vim.</li>
<li><a href="http://astonj.com/tech/vim-for-ruby-rails-and-a-sexy-theme/">Vim for Ruby and Rails</a> - Getting started with Ruby, Rails and Vim</li>
<li><a href="http://blog.danielfischer.com/2010/11/19/a-starting-guide-to-vim-from-textmate/">From TextMate to Vim</a> - Useful for people coming from TextMate</li>
<li><a href="http://robots.thoughtbot.com/post/166073596/intro-rails-vim">Intro - Rails Vim</a> - Rails and Vim</li>
</ul>


<h2>Conclusion</h2>

<p>There are a lot of Rubyists doing web development with Vim. Besides being ruby evangelists, they also contribute to a huge
amount of Vim plugins. So, if you are going to migrate to Vim, you are in a good company.</p>

<p>What&#8217;s your favourite Vim plugin for Ruby? Do you have any special Vim tricks for writing Ruby code?
Which Vim features had the greatest influence on you? Let us know in the comments.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[10 vim color schemes you need to own]]></title>
    <link href="http://www.vimninjas.com/2012/08/26/10-vim-color-schemes-you-need-to-own/"/>
    <updated>2012-08-26T13:12:00+03:00</updated>
    <id>http://www.vimninjas.com/2012/08/26/10-vim-color-schemes-you-need-to-own</id>
    <content type="html"><![CDATA[<p><img src="http://www.vimninjas.com/images/posts/10vim/cover.png" alt="10 Vim color schemes you need to own" /></p>

<p>There are a lot of Vim color schemes out there. It&#8217;s always hard to find the perfect one.
People often use different color schemes depending on what they are working on.
This is pretty neat approach that has plenty of supporters. That&#8217;s why we did a quick overview of our top 10 themes. Let&#8217;s go:</p>

<!-- more -->


<h2>1. GRB256</h2>

<p><img src="http://www.vimninjas.com/images/posts/10vim/grb256.png" alt="grb256" /></p>

<p>GRB256 is a color scheme based on ir_black by Gary Bernhardt. It feels really
nice especially for Ruby on Rails development, so give it a try.</p>

<p>Download: <a href="https://github.com/garybernhardt/dotfiles/blob/master/.vim/colors/grb256.vim">GitHub</a></p>

<p>Author: <a href="http://destroyallsoftware.com">Gary Bernhardt</a></p>

<h2>2. Guardian</h2>

<p><img src="http://www.vimninjas.com/images/posts/10vim/guardian.png" alt="Guardian" /></p>

<p>Guardian is originally created for XHTML and CSS editing, however you can use it for
Ruby and JavaScript development as well.</p>

<p>Download: <a href="http://www.vim.org/scripts/script.php?script_id=1240">Vim.org</a></p>

<p>Author: <a href="http://www.vim.org/account/profile.php?user_id=6122">M. L. (anderskorte)</a></p>

<h2>3. Codeschool</h2>

<p><img src="http://www.vimninjas.com/images/posts/10vim/codeschool.png" alt="Codeschool" /></p>

<p>The author created this color scheme to mimic the CodeSchool theme used in their Rails Best
Practises course. It is ported to Vim using Coloration.</p>

<p>Download: <a href="http://astonj.com/tech/vim-for-ruby-rails-and-a-sexy-theme/">astonj</a></p>

<p>Author: <a href="http://astonj.com/">AstonJ</a></p>

<h2>4. Distinguished</h2>

<p><img src="http://www.vimninjas.com/images/posts/10vim/distinguished.png" alt="Distinguished" /></p>

<p>Distinguished is a dark Vim color scheme for 256-color terminals. It&#8217;s often used in the
terminal Vim. It&#8217;s perfect for JavaScript development. Works great for
Ruby and Python too.</p>

<p>Download: <a href="https://github.com/Lokaltog/vim-distinguished">GitHub</a></p>

<p>Author: <a href="https://github.com/Lokaltog">Kim Silkebækken</a></p>

<h2>5. GitHub</h2>

<p><img src="http://www.vimninjas.com/images/posts/10vim/github.png" alt="GitHub" /></p>

<p>This color scheme is a port of GitHub&#8217;s light-background syntax highlighting theme.
It looks good with completion menus, diffsplit, STL highlighting and more.</p>

<p>Download: <a href="http://www.vim.org/scripts/script.php?script_id=2855">Vim.org</a></p>

<p>Author: <a href="http://www.vim.org/account/profile.php?user_id=18383">Anthony Carapetis</a></p>

<h2>6. Jellybeans</h2>

<p><img src="http://www.vimninjas.com/images/posts/10vim/jellybean.png" alt="Jellybeans" /></p>

<p>Jellybeans is a colorful color scheme, inspired by ir_black and twilight.
It&#8217;s designed primarily for gVim/MacVim, but also includes support for 256 color terminals.</p>

<p>Download: <a href="https://github.com/nanotech/jellybeans.vim">GitHub</a></p>

<p>Author: <a href="http://nanotech.nanotechcorp.net/">nanotech</a></p>

<h2>7. Railscasts</h2>

<p><img src="http://www.vimninjas.com/images/posts/10vim/railscasts.png" alt="Railscasts" /></p>

<p>Ryan Bates ported his TextMate color scheme used in the RailsCasts episodes to Vim.
If you write Ruby code most of the time, you should definitely try it.</p>

<p>Download: <a href="https://github.com/ryanb/dotfiles/blob/master/vim/colors/railscasts.vim">GitHub</a></p>

<p>Author: <a href="http://railscasts.com/">Ryan Bates</a></p>

<h2>8. Twilight</h2>

<p><img src="http://www.vimninjas.com/images/posts/10vim/twilight.png" alt="Twilight" /></p>

<p>Twilight is a clone of TextMate&#8217;s twilight scheme. There are a lot of Twilight clones
out there, but it seems this is the most preferred. It&#8217;s not exactly the same as the original,
but in some cases it feels even better. If you are coming from TextMate, we encourage you to
give it a try.</p>

<p>Download: <a href="http://www.vim.org/scripts/script.php?script_id=1677">Vim.org</a></p>

<p>Author: <a href="http://leetless.de/">Henning Hasemann</a></p>

<h2>9. Vividchalk</h2>

<p><img src="http://www.vimninjas.com/images/posts/10vim/vividchalk.png" alt="Vividchalk" /></p>

<p>This color scheme is another theme ported from TextMate to Vim. It is based on the Vibrant Ink theme TextMate.
GUI, 256, 88, and even 16 color terminals are supported.</p>

<p>Download: <a href="https://github.com/tpope/vim-vividchalk">GitHub</a></p>

<p>Author: <a href="http://tpo.pe/">Tim Pope</a></p>

<h2>10. Candy</h2>

<p><img src="http://www.vimninjas.com/images/posts/10vim/candy.png" alt="Candy" /></p>

<p>Candy is one of the hidden color schemes in the Vim world that you can&#8217;t find easily.
Feel free to download it and use it right away.</p>

<p>Download: <a href="http://www.vim.org/scripts/script.php?script_id=282">Vim.org</a></p>

<p>Author: <a href="http://www.vim.org/account/profile.php?user_id=495">Tiza</a></p>

<h2>Bonus: Solarized</h2>

<p><img src="http://www.vimninjas.com/images/posts/10vim/solarized.png" alt="Solarized" /></p>

<p>You almost thought it won&#8217;t be included, didn&#8217;t you? Solarized is probably the most
popular color scheme out there. If you haven&#8217;t tried it yet, you should download and
start using it immediately.</p>

<p>Download: <a href="https://github.com/altercation/vim-colors-solarized">GitHub</a></p>

<p>Author: <a href="http://ethanschoonover.com/">Ethan Schoonover</a></p>

<p>As you can easily guess we prefer dark color schemes. However, if you know
amazing light theme that deserve to be included just send us a link
and it will be featured in the list.</p>

<p>What&#8217;s your favourite color scheme? Do you prefer different color schemes for
terminal Vim and MacVim/gVim? Let us know.</p>
]]></content>
  </entry>
  
</feed>
