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:
:Ris the prefix for your main rails navigation commands.
:RV file_namewill do a vertical split
:RS file_namewill do a horizontal split
:RT file_namewill open the file in a new tab
There are commands that will take you to specific directories:
Rviwill give you views
Rcowill give you controllers
Rmowill give you models
These commands can be paired to create the following:
:RVvi home/index.htmlwould open index.html in a vertical split
:RSmo userwould open user.rb in a horizontal split
:RTco commentswould open comments_controller.rb in a new tab.
:Rvi users/new.htmlwould 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.
- :Rmo users
- Open users model
- :Rco users
- Open users controller
- :Rvi users/index.html
- Open view users/index.html
- Vertical split alternate file
- Go to file under cursor