---
title: Intro to Vim for Rails Development
teaser:
tags: news,web,vim,rails
author: Dan Croak
published_on: 2009-08-19
---

Someone recently asked us to do "vim on Rails" screencasts.  So, we're
responding with this experiment. Let us know if this is valuable and we'll try
to improve things like audio quality.

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0"
  width="560" height="345">
  <param name="movie" value="http://screenr.com/Content/assets/screenr_0817090731.swf"
    />
  <embed src="http://screenr.com/Content/assets/screenr_0817090731.swf" width="560"
    height="345" />
</object>

## Install thoughtbot/dotfiles

    git clone git://github.com/thoughtbot/dotfiles.git
    cd dotfiles
    ./install.sh

## Installing Vim

If you're on a UNIX machine, you probably have vi. You may also have vim. Try
running `vim` from the command line.

Many of us on Apple laptops prefer MacVim. [Download the installer](http://code.google.com/p/macvim/).

It’s nice to have the `mvim` command from your shell, so copy it from wherever
your downloaded MacVim to into a place where you keep scripts. I use ~/bin:

    cp ~/Downloads/MacVim-7_2-stable-1_2/mvim ~/bin

## rails.vim

The grandaddy vim plugin we use as Rails developer's is Tim Pope's rails.vim.
Read the [rails.vim documentation](http://rails.vim.tpope.net).

## Basic commands

Move to a file in your app:

    :Rmodel user
    :Rcontroller application
    :Rhelper navigation
    :Rview sessions/new
    :Rfunctionaltest sessions
    :Runittest user

Go to the alternate file:

    :A

Go to the file under cursor:

    gf

Enter into insert mode:

    i

Exit insert mode:

    esc

Open and close folded code (mnemonic is imagining the Z as [tractor feed printer
paper](http://s3.amazonaws.com/thoughtbot-training/images/tractor_feed_printer_paper.png)
and o for open, c for closed) :

    :zo
    :zc
