1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Using rails.vim


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.

  1. About.com
  2. Technology
  3. Ruby
  4. Ruby on Rails
  5. Jumping Between Files

©2014 About.com. All rights reserved.