1. Home
  2. Computing & Technology
  3. Ruby

Using rails.vim

By Amanda & Michael Morin, About.com

4 of 6

Jumping Between Files

The biggest problem to solve when editing Rails applications is jumping between many files. Without any scripts, this is a difficult task in Vim. The following commands will help switch between files.

  • :Rmodel, :Rmigration, :Robserver, :Rfixtures and :Runittest

    These commands will quickly switch to their respective model-related files based on any arguments given. For example, to edit the Post model, you can simply type the command :Rmodel post and rails.vim will find the file for you.

  • :Rcontroller, :Rhelper, :Rview, :Rlayout, :Rfunctionaltest

    These commands will switch quickly to their respective controller-related files. For example, to edit the Posts controller simply type the command :Rcontroller posts. Some commands, such as the Rview command must have both a controller name and view name. To edit the edit.html.erb template for the posts controller, type the command :Rview posts/edit.

  • Jumping to Other Files

    The :Rfind command can be used to jump to various other files. For instance, to switch to routes.rb you can use the command :Rfind routes or to switch to database.yml you can use :Rfind database.

In addition to the commands above, rails.vim also integrates with the project.vim script. Issuing the :Rproject command while in the base directory of a Rails application will open a project window organized by models, views, controllers, etc. This can be used for graphical navigation instead of command-based navigation.

Explore Ruby
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Ruby
  4. Ruby on Rails
  5. Jumping Between Files

©2009 About.com, a part of The New York Times Company.

All rights reserved.