Skip to content
This repository

rails.vim: Ruby on Rails power tools

Fetching latest commit…

Cannot retrieve the latest commit at this time




  • Easy navigation of the Rails directory structure. gf considers context and knows about partials, fixtures, and much more. There are two commands, :A (alternate) and :R (related) for easy jumping between files, including favorites like model to migration, template to helper, and controller to functional test. For more advanced usage, :Rmodel, :Rview, :Rcontroller, and several other commands are provided. :help rails-navigation



  • Interface to script/*. Generally, use :Rscript about to call script/about or script/rails about. Most commands have wrappers with additional features: :Rgenerate controller Blog generates a blog controller and edits app/controllers/blog_controller.rb. :help rails-scripts

  • Partial extraction and migration inversion. :Rextract {file} replaces the desired range (ideally selected in visual line mode) with render :partial => '{file}', which is automatically created with your content. The @{file} instance variable is replaced with the {file} local variable. :Rinvert takes a self.up migration and writes a self.down. :help rails-refactoring

  • Integration with other plugins. :Rtree spawns NERDTree.vim. If dbext.vim is installed, it will be transparently configured to reflect database.yml. Users of abolish.vim get pluralize and tableize coercions, and users of bundler.vim get bundle exec rake. :help rails-integration



cd ~/.vim/bundle
git clone git://







Can I use rails.vim to edit other Ruby projects?


Is Rails 3 supported yet?

Of course.

Is Rails 2 still supported?

Baby, you can go all the way back to Rails 1 if you like (give or take some syntax highlighting).

Rake is slow. How about making :Rake run testrb/rspec/cucumber directly instead of rake?

Well then it wouldn't make sense to call it :Rake, now, would it? Maybe one day I'll add a separate :Run command or something. In the meantime, here's how you can set up :make to run the current test:

autocmd FileType cucumber compiler cucumber | setl makeprg=cucumber\ \"%:p\"
autocmd FileType ruby
      \ if expand('%') =~# '_test\.rb$' |
      \   compiler rubyunit | setl makeprg=testrb\ \"%:p\" |
      \ elseif expand('%') =~# '_spec\.rb$' |
      \   compiler rspec | setl makeprg=rspec\ \"%:p\" |
      \ else |
      \   compiler ruby | setl makeprg=ruby\ -wc\ \"%:p\" |
      \ endif
autocmd User Bundler
      \ if &makeprg !~ 'bundle' | setl makeprg^=bundle\ exec\  | endif



Beyond that, don't be shy about asking before patching. What takes you hours might take me minutes simply because I have both domain knowledge and a perverse knowledge of VimScript so vast that many would consider it a symptom of mental illness. On the flip side, some ideas I'll reject no matter how good the implementation is. "Send a patch" is an edge case answer in my book.





Something went wrong with that request. Please try again.