Ruby on Rails Syntax Highlighting in Vim

Vim has a pretty steep learning curve as text editors go, but it’s still my favorite. One thing that makes vim so great is the abundance of plugins available for it. Here we’ll quickly add a plugin for ruby on rails that will add syntax highlighting and a whole slew of other cool features.

First, download the latest rails.vim plugin here and unzip the file.

Open a shell prompt, move into your home directory, and check for a .vimrc file.

cd  ls -a     

If there isn’t already a .vimrc file, create one.

touch .vimrc 

Open .vimrc and add the following lines

set nocompatible  
syntax on  
filetype plugin indent on
set tabstop=2 

Save and close.

Now, still in your home directory, check for a .vim directory. If there isn’t one create it

mkdir .vim

Now copy all of the contents you extracted from the rails.vim plugin to your .vim directory.

Open a file from a rails project in vim and behold the goodness! Rails.vim does much more than just syntax highlighting. It is “rails aware” and adds some very helpful commands for navigating between related files, running rake tasks and more. Check out it’s documentation for all of the features.

comments powered by Disqus