ruby on rails vim auto complete

Vim can detect and load the Rails environment for files within a rails project. The feature is disabled by default, to enable it add
let g:rubycomplete_rails = 1
to your vimrc

 

 

autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete

autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1

autocmd FileType ruby,eruby let g:rubycomplete_rails = 1

autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1

autocmd FileType ruby,eruby let g:rubycomplete_include_object = 1

autocmd FileType ruby,eruby let g:rubycomplete_include_objectspace = 1

 

--------------------------------------------------------------------------------------------------------

Vim and Ruby fit together like beer and pizza, music and dancing: each an art form unto itself, but together they transcend, uh, somersaulting goose bumps. If you aren't already getting to that level with Vim and Ruby you might want to look into the following two Vim plugins: rubycomplete andsupertab. Rubycomplete gives you autocomplete for variable names, method names, etc., just like you get in your IDE. Supertab hooks that functionality to the tab key (among other awesomeness), so just like at the command line you can tab complete your thoughts. Wheee!

One side note. To use rubycomplete you need to have a version of vim compiled with ruby support, otherwise you get an error message like this: "E486: Pattern not found: ErrMsg( "Error: Required vim compiled with +ruby"). To get your own version of vim with ruby support compiled in use MacPorts. The precise command you want is 'sudo port install vim +ruby'. On linux you can just apt-get the vim-ruby package and it comes with the plugin by default (but you still have to get supertab yourself). Another technical detail: you need to modify your ~/.vimrc to support all this hotness.

"ruby
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
"improve autocomplete menu color
highlight Pmenu ctermbg=238 gui=bold

That last bit with the highlight command is there to fix the default rubycomplete color scheme. Out of the box it has a horrible, horrible pink background to the menu.

As an extra bonus, if you like textmate's cmd-T action you'll want to look into  fuzzyfinder_textmate. Another awesome vim plugin. Also, because color is key, look into some good vim colorschemes. I use the vividchalk vim colorscheme on my mac and desert256 on linux (see screenshot). desert256 is my favorite but I can't get 256 color support working on my mac, so i settle for vividchalk.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值