Installing the Rails.Vim plugin for VIM

February 7th, 2008  | Tags:

Hey guys,

In this topic I am going to talk about a fantastic Rails.Vim plugin for VIM. With this plugin, you can improve your productivity using VIM.

I advice you to take a look at this topic: http://www.jairrillo.com/blog/2008/01/07/installing-vim-ruby-on-ubuntu-710/ and configure the vim-ruby plugin before install the Rails.Vim plugin.

The rails plugin has been writen by Tim Pope and the current version works for rails 2.0

Installing the Rails Vim

Go to the official Rails.vim page: http://www.vim.org/scripts/script.php?script_id=1567 and get the latest version.

Extract the zip file and copy the rails.txt into ~/.vim/doc and rails.vim into ~/.vim/plugin directory.

Done, the plugin has already been installed. It’s simple, huh?

Testing the Rails.Vim plugin

Open the VIM editor e type:

:Rails <project name>

A project is going to be created :)

Note: Fell free to use the –database argument for the :Rails command

To create a controller, simply type the following:

:Rgenerate controller test_controller

The controller is going to be created and the test_controller.rb file is going to be opened by the vim.

Supposing you are within a controller code and there is a method index (associated a index.html.erb page), put the cursor on def index method and type :RA

The index.html.erb page is going to be opened.

If you want to open a controller already created, type the following:

:Rcontroller <controller name>

It also can be used for :Rmodel, :Rlayout and …

:Rview <controller name>/<view name>

To run the server, simply type:

:Rserver

If you want to restart the server, type the same commando plus !, like below:

:Rserver!

If you are in the HTML file and there is a :action => “any_action”, put the cursor on “any_action” and type gf. The action selected is going to be opened.

Also take a look at the :Rjavascript, :Rstylesheet and :Rtags

There are many useful commands and I advice you to take a deep look at the doc file.

I hope this topic, and this plugin, be useful for anyone.

No comments yet.
TOP