接下來有幾個指令一定要特別提出來講。這是rails.vim最強大的部份:

1. gf

gf這個指令根據游標所在的位置不同會有不同的效果,直接看例子(*代表游標的位置)
游標的位置 打開的檔案
Pos*t.find(:first) app/models/post.rb
has_many :c*ommentsapp/models/comment.rb
link_to "Home", :controller => :bl*ogapp/controllers/blog_controller.rb
= render :partial => 'sh*ared/sidebar' app/views/shared/_sidebar.rhtml
%= stylesheet_link_tag :scaf*fold public/stylesheets/scaffold.css
甚至,假設我們有個admin_controller 中有一段程式碼: def s*ay ... end 輸入gf就會馬上切換到say對應的view (app/views/admin/say.rhtml) 是不是很強大呢?

2. :R跟:A

這兩個指令也是在不同的檔案間切換用的,運作方式如下:
目前的檔案輸入:A會切換到輸入:R會切換到
model 對應的unit test 對應的migration
controller (in method) 對應的functional test 對應的template (view)
template (view) 對應的helper 對應的controller中method的位置
migration 前一版的migration 下一版的next migration
創作者介紹
創作者 PogaPress 的頭像
poga

PogaPress

poga 發表在 痞客邦 留言(0) 人氣( 12 )