2009-06-18 2 views
1

OSX 또는 Ubuntu의 레일 개발에 vim (콘솔에서) 7.1을 사용합니다. 다음은 레일 파일을 편집 할 때 반복적으로 수행하는 작업입니다.rails.vim 자동화

CD를 RAILS_ROOT 정력

: Rproject는

마지막 부분이 자동으로 수행하는 방법이 있나요

을의 .project? 예를 들어 'vim -some_arg'을 입력하면 자동으로 ": Rproject .project"가 트리거됩니까? 그럴 수 없다면 "Rproject .project"의 별칭을 "Rp"로 지정할 수 있습니까?

저는 vim 편집에 익숙하지만 vim 스크립트에는 익숙하지 않습니다. 도와주세요.

샘이이 할 수있는 더 나은 방법이 아마도,하지만 난로드 순서 등으로 장난처럼 생각하지 않습니다

답변

3

.

rails.vim을 편집하고 한 줄을 추가 할 수 있습니다. 그것은 내 테스트에서 기대했던대로 작동합니다.

" Initialization {{{1 

augroup railsPluginDetect 
    autocmd! 
    autocmd BufNewFile,BufRead * call s:Detect(expand("<afile>:p")) 
    autocmd VimEnter * if expand("<amatch>") == "" && !exists("b:rails_root") | call s:Detect(getcwd()) | endif | if exists("b:rails_root") | silent doau User BufEnterRails | endif 
    autocmd FileType netrw if !exists("b:rails_root") | call s:Detect(expand("<afile>:p")) | endif | if exists("b:rails_root") | silent doau User BufEnterRails | endif 
    autocmd BufEnter * if exists("b:rails_root")|silent doau User BufEnterRails|endif 
    autocmd BufLeave * if exists("b:rails_root")|silent doau User BufLeaveRails|endif 
    autocmd Syntax railslog if s:autoload()|call rails#log_syntax()|endif 

    " Add this line here 
    autocmd VimEnter * if expand("<amatch>") == "" && !exists("b:rails_root") | call s:Detect(getcwd()) | endif | if exists("b:rails_root") | Rproject .project | endif 
    "^this one 

augroup END