vim-rails는 Tim Pope가 제작한 Ruby on Rails 개발을 위한 종합적인 Vim 플러그인입니다.
Rails 프로젝트 탐색
대체 파일 및 연관 파일 점프
| 명령어 | 설명 |
|---|---|
:A |
대체 파일로 이동 (예: 테스트 / spec 파일) |
:R |
연관 파일로 이동 (예: 컨트롤러 / 뷰 / 스키마 파일) |
| 현재 컨텍스트 | :A 이동 대상 | :R 이동 대상 |
|---|---|---|
| 모델 (Model) | test/models/ or spec/models/ |
db/schema.rb |
| 컨트롤러 (Controller) | test/controllers/ or spec/controllers/ |
app/views/<controller>/ |
| 뷰 템플릿 (View Template) | test/views/ or spec/views/ |
app/controllers/<controller>_controller.rb |
파셜(Partial) 및 Concern 추출
" ERB/Haml 뷰에서 파셜 파일로 추출 => app/views/home/_foo_partial.html.erb
:Rextract home/foo_partial
" 모델에서 Concern 모듈 파일로 추출 => app/models/concerns/foo_concern.rb
:Rextract FooConcern
Rails 파일 바로 열기
애플리케이션 코드
:Econtroller <name> # app/controllers/*_controller.rb
:Ehelper <name> # app/helpers/*_helper.rb
:Emodel <name> # app/models/*.rb
:Ejob <name> # app/jobs/*_job.rb
:Emailer <name> # app/mailers/*.rb
데이터베이스 및 마이그레이션
:Emigration <name> # db/migrate/*.rb
:Eschema # db/schema.rb
라이브러리 및 Rake 태스크
:Elib <name> # lib/*.rb
:Elib # Gemfile
:Etask <name> # lib/tasks/*.rake
뷰 및 레이아웃
:Eview <name> # app/views/...
:Elayout <name> # app/views/layouts/...
테스트 및 스펙
:Espec <name> # spec/.../*_spec.rb
:Eunittest <name> # test/models/..._test.rb
:Efunctionaltest <name> # test/controllers/..._test.rb
:Eintegrationtest <name># test/integration/..._test.rb
:Efixtures <name> # test/fixtures/*.yml
설정 파일
:Einitializer <name> # config/initializers/*.rb
:Elocale <name> # config/locales/*.yml
:Eenvironment # config/application.rb
:Eenvironment development # config/environments/development.rb
기본 내장 축약어 (Abbreviations)
Vim에서 :Rabbrev 명령을 실행하면 사용 가능한 전체 축약어 목록을 확인할 수 있습니다.
모델 축약어
| 축약어 | 확장 결과 |
|---|---|
bt( |
belongs_to |
hm( |
has_many |
ho( |
has_one |
habtm( |
has_and_belongs_to_many |
컨트롤러 축약어
| 축약어 | 확장 결과 |
|---|---|
pa[ |
params |
re( |
redirect_to |
rp( |
render partial: |
rst( |
respond_to |