… so here’s Snipmate for your Vim so you can TextMate while you Vim.

TextMate is great. My most favourite TextMate feature are the Snippets. What is a Snippet? A Snippet is a piece of code that defines the editors helpful behaviour in a given context. Sounds complicated? Well it’s really not. Here’s how it works:

TextMate Snippet video example

The second Snippet used here, namely the opt⇥ looks like this inside:

snippet code example

opts.on( "-${1:o}", "--${2:long-option-name}${6: }"${3/^\s*$|(.*\S.*)/(?1:, )/}${3:String},
         "${4:Option description.}" ) do |$2|
    options[:$2] = $2
end
$5

This basically defines what to initialy put when opt⇥ is entered, and were are the cursor jump points after the initial template is inserted.

TextMate is a really cool tool - but it is a commercial tool. One of it’s major competitors Sublime Text is also commercial. Both of those editors are also not exaclty cheap.

But fear not, there is one reliable piece of software that has been there almost forever for every Unix SysAdmin, SysOp, DevOp, WhateverOp. I mean off course Ema… Vim!

Things you need

  • Vim
  • pathogen Vim plugin
  • git

If you don’t already use the pathogen plugin, do it right now. By the way - Tim Pope, the author of pathogen is the goto man for your Vim plugin needs. Follow the instructions provided by the link above to install the plugin.

making it work

After installing pathogen, you should have you ~/.vim/bundle directory. All you need to do now in your terminal is:

cd ~/.vim/bundle
git clone https://github.com/garbas/vim-snipmate
git clone https://github.com/vim-scripts/tlib.git
git clone https://github.com/vim-scripts/vim-addon-mw-utils.git
git clone https://github.com/honza/snipmate-snippets.git

This will download Snipmate and and its dependencies straight into your ~/.vim/bundle directory, from which pathogen will auto-load them once you start Vim.

And voila:

Snipmate Snippet video example

After having successfully added the Snippets functionality it would be nice to make Vim a little prettier, by making use of all the 256 colors a modern terminal emulator usually provides and installing a clone of Ryan Bates “railscasts” color schemes. But that is a subject for another post, another time.