Setting up VIM for Rails Development 27 May 2012

Here is a list of some of the tools we need, to use Vim for Rails Development or for any software development for that matter.

  • File browser
  • Quickly Open Files
  • Searching
  • Goto method definitions
  • Snippets
  • Commenting

Install VIM

  sudo apt-get install vim vim-gnome vim-gui-common

Setting up Directories

mkdir ~/vim
mkdir ~/vim/bundle
mkdir ~/vim/autoload
ln -s ~/vim ~/.vim
cd ~/vim
touch vimrc
touch gvimrc
git init

VIM Plugins


Pathogen is a plugin manager for Vim.

curl -so autoload/pathogen.vim

Add the following to ~/vim/vimrc

call pathogen#infect()

NerdTree (File browser)

A tree explorer plugin for navigating the filesystem

git submodule add bundle/nerdtree

Command-T (Quickly Open Files)

Fast file navigation for VIM

sudo apt-get install ruby1.8 rubygems1.8
sudo gem install bundler
git submodule add bundle/command-T
cd bundle/commant-T
bundle install
rake make

Goto your project folder and use “Leader t”.

Plugin for the Perl module / CLI script ‘ack’

sudo apt-get install ack-grep
git submodule add bundle/ack

Ack config
This will search for the word config in your project.
Use :cn and :cp to navigate between search results

Ctags (Goto Method Definition)

sudo apt-get install exuberant-ctags
ctags -R --exclude=.git --exclude=.svn --exclude=log *

Run the above command in your project folder. This will generate a tags file
To goto a definition of a method just take your cursor on the method and use Ctrl + ]
To go back to previous position use Ctrl + o

Snipmate (Code Snippets)

git submodule add bundle/snipmate

Snipmate Snippets

git submodule add bundle/snipmate-snippets

Use Tab after entering the snippet shortcut

TComment (Comment blocks of code)

git submodule add bundle/tcomment

Select a block and use gcc to comment the block.
Use gc to comment current line


git submodule add git:// bundle/vim-rails

Fugitive (Git from Vim)

git submodule add bundle/fugitive

Color Schemes

git submodule add bundle/colors

Finally Commit to Github

git add .
git commit -m "Vim configutation packages"
git remote add origin
git pull origin master
git push origin master

Next time you can clone this repository and get started with your development

Happy Editing.


comments powered by Disqus