Before you start…
If you use Rails, rails.vim is a must-know. It greatly simplifies navigation in a Rails app and it gives you many handy shortcuts.
Here's the basic gist of it:
:R
is the prefix for your main rails navigation commands.:RV file_name
will do a vertical split:RS file_name
will do a horizontal split:RT file_name
will open the file in a new tab
There are commands that will take you to specific directories:
:Rview
orRvi
will give you views:Rcontroller
orRco
will give you controllers:Rmodel
orRmo
will give you models
These commands can be paired to create the following:
:RVvi home/index.html
would open index.html in a vertical split:RSmo user
would open user.rb in a horizontal split:RTco comments
would open comments_controller.rb in a new tab.:Rvi users/new.html
would open new.html, replacing whatever you have currently open.
:A
gives you the "alternate" file for your currently open file. E.g., if you're in a model, and you type :AV,
then the spec for that model will open up in a vertical split. Pretty nifty, right?
Ok, I hope you got all that, 'cause here's the quiz.
Up Next
- :Rmo users
- Open users model
- :Rco users
- Open users controller
- :Rvi users/index.html
- Open view users/index.html
- :AV
- Vertical split alternate file
- gf
- Go to file under cursor