Tuesday, December 29, 2009

VIM Destroys All Other Rails Editors

Updated on February 06, 2010 to account for updates in pathogen.vim 1.2

Updated on February 10, 2010 to account for set up difficulties some Linux users were experiencing

Now that I have your attention, I've come across quite a few blog and forum posts from people looking for "the best" text editor or IDE to use for Ruby on Rails development. I was fortunate enough to meet Tim Pope soon after I got interested in Rails and was subsequently introduced to the awesomeness that Vim is capable of. It took some ramp up time to get comfortable with modal editing but now I find myself frustrated when I don't have all the power that comes from Vim's modal mindset.

Flame War Disclaimer

What you use to edit code is any other tool and it comes down to personal preference. Personally I LOVE Vim. There are hundred different ways you could set up Vim. This is the setup that's worked best for me. Hope you enjoy it as well.

First things first

Install MacVim or Gvim (For Debian based distros install with apt-get). I do frequently use terminal Vim or Vi but I like having both available. If you're on Windows you probably want to spin up a Linux box or a VM. Ruby on Rails development on Windows is going to painful.

Let's Get Plugged In

Download pathogen.vim it makes managing Vim plugins a lot simpler. Create a ~/.vim/autoload/ directory and copy pathogen.vim into it.
$ mkdir ~/.vim
$ mkdir ~/.vim/autoload
$ cp ~/Downloads/pathogen.vim ~/.vim/autoload/
Next you need to create and edit your .vimrc file so that pathogen gets loaded in the correct order.
$ mvim ~/.vimrc
Content:
filetype off

call pathogen#runtime_append_all_bundles()

syntax on
filetype plugin indent on
set tabstop=2
set smarttab
set shiftwidth=2
set autoindent
set expandtab
The "filetype off" is necessary for some Linux distros. If you're on OS X you should be able to omit that though it won't hurt either way if you leave it in.

Create a .gvimrc to specify colorscheme
$ mvim ~/.gvimrc
Content:
colorscheme vividchalk
I've also become fond of the molokai colorscheme. But its all personal preference. You can also forgo the .gvimrc file and just specify your colorscheme in .vimrc but if you are using terminal vim loading some colorschemes doesn't work very well. Putting it in the .gvimrc will only load the custom colorscheme when you are in Gvim or MacVim.

http://www.vim.org/scripts/script.php?script_id=2340

Create a ~/.vim/bundle directory and install plugins. I prefer to clone them from github.com when I can. Some plugins still need to be downloaded from vim.org, extracted and copied to your .vimbundles directory. Either way go vote up plugins you find useful on vim.org. If you don't have git installed check out git-scm.com
$ mkdir ~/.vim/bundle
$ cd ~/.vim/bundle
Install rails.vim
$ git clone git://github.com/tpope/vim-rails.git
Install cucumber.vim
$ git clone git://github.com/tpope/vim-cucumber.git
Install vividchalk.vim
$ git clone git://github.com/tpope/vim-vividchalk.git
Install haml.vim (There are two. I use Tim Pope's.)
$ git clone git://github.com/tpope/vim-haml.git
Install endwise.vim
$ git clone git://github.com/tpope/vim-endwise.git
Install surround.vim
$ git clone git://github.com/tpope/vim-surround.git
Install unimpaired.vim
$ git clone git://github.com/tpope/vim-unimpaired.git
Install abolish.vim
$ git clone git://github.com/tpope/vim-abolish.git
Install repeat.vim
$ git clone git://github.com/tpope/vim-repeat.git
Install NERD_tree.vim
$ git clone git://github.com/scrooloose/nerdtree.git
Install NERD_commenter.vim
$ git clone git://github.com/scrooloose/nerdcommenter.git
Restart Vim and you now have a super powerful Rails editor at your fingertips. Check out each of the plugins for documentation of features.

Technorati Tags: , ,

Saturday, December 26, 2009

Story Card Faster Than The Speed Of Pivotal Tracker

Pivotal Tracker Does Some Things Really Well.....

It provides a very streamlined and convenient tool for managing story cards with clients. This is especially true when your client is not on site with you on an ongoing basis. It does a solid job of fostering collaborative ownership of project scope and allows clients to see their impact on the project in a very tangible fashion. These things are all great once there are stories in Pivotal Tracker. Sometimes getting stories into Pivotal Tracker can be a frustrating experience.

Pivotal Tracker Can Be Frustrating.....

When I found myself on the receiving end of a brain dump by a client or in a room with flaky wireless I frequently got burned by the limitation of how fast Pivotal Tracker's UI would let me create new stories or by lost stories when then internet fizzled out.

The Solution
.....

One of my fellow Rocketeers, Wes Gibbs had the idea for and wrote a ruby script called slurper that allowed us to compose stories in a plain text file and then slurp them into Pivotal Tracker through the api. After a few iterations of improvements with contributions by myself, Tim Pope and Stephen Caudill it has been released as a gem.

Install the slurper gem
$ gem install slurper
Create a story_defaults.yml file in your working directory and add your configuration information.
project_id: 1234
token: 123abc123abc123abc
requested_by: Jane Stakeholder
Create a stories.slurper file in your working directory and open in vim. Compose your stories in the slurper story format.



Save your file and slurp the stories into Pivotal Tracker.
$ slurp stories.slurper

It Gets Better
.....

slurper is great. It's much faster than working through the Pivotal UI. It adds the additional bonuses of not having to worry about losing stories to flaky internet and being able to archive your story files in a dropbox folder or Basecamp for historical purposes.

Eventually I found having to compose the stories in the slurper format still wasn't fast enough. To solve this I wrote the slurper.vim plugin.
The plugin generates story templates for you via key maps. Fill in the details for each story, wash, rinse and repeat.

There is a detailed readme available for both projects on their respective github pages with installation, configuration and usage information. They currently follow the Hashrocket Way format for writing stories.

slurper github.com/hashrocket/slurper

slurper.vim github.com/alowe/vim-slurper

Technorati Tags: , , ,

Saturday, December 5, 2009

RubyJax December Presentation

Come Check Out My Presentation at RubyJax December: Sinatra, Heroku, and You, and You

I will be presenting a demo on building a Sinatra app and deploying via Git to Heroku. I will cover a basic introduction to Sinatra, a flexible and light weight Ruby web framework. I will also cover leveraging the pony gem for mail via Gmail and Big Tiger will talk about authentication with Sinatra apps. Sinatra provides an amazingly lightweight, simple solution for quickly deploying low complexity sites or services. Location is the Hashrocket offices and we will follow up the presentation with a hackfest to pair program on sinatra apps with everyone that makes it out.

Please RSVP on the meetup.com page. Look forward to seeing you there.

Slides are available on Slideshare in in Keynote and PDF format. Sorry to any Powerpoint folks out there but I'm tired of trying to clean up slides to look right when exported to .ppt.