vim ctags goto definition and omni-complete August 16th, 2008
When you're reviewing or writing lots of code, it helps to have a sharp tool. I prefer to write ruby and just about everything else in vim since it's available on all platforms and I'm constantly switching from platform to platform (mostly Linux and OSX these days though).
Vim is a great, lightweight, powerful editor with all the features that any other editor can provide (yeah, even the famed textmate has nothing vim doesn't have). The steps below can get you going at a birds eye view.
1) compile vim with ruby support (if you don't already have it). To see if ruby support is enabled type 'vim --version' and look for "+ruby". If you see "-ruby" then ruby support is not enabled.
2) install ctags (via apt-get or ports). You can run it in your project's directory and jump-to-definition will start working:
ctags -R --exclude=*.js
3) install the rails-vim plugin into ~/.vim
4) cook up a great .vimrc
set smartindent
let g:rails_menu=2
set viminfo^=!
colorscheme desert
syntax on
set path=~/myproject/trunk/**
set tabstop=2
set expandtab
set shiftwidth=2
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
VIM commandsJump to tag (ie: go to definition of the method under your cursor)
Control + ]
Bring up the OMNI complete window in insert mode
Control+X Control+O
Textmate style rails plugins for VIM. October 11th, 2007
"Textmate is cool, but VI is forever"
Here's how to get some textmate like potential out of VIM using plugins.
I have the following plugins installed: project.vim, genutils.vim, rails.vim, multvals.vim, rubycomplete.vim and surround.vim.
non-insert mode
| what to type | what it does |
| :help surround | shows help for the surround plugin |
| yss= | surrounds the current line with <%= %> |
| yss CTRL-E | turns the current line into a block <% -%>newline char<% end -%> |
| yss- | surrounds the current line with <% -%> |
| CTRL-X CTRL-O | brings up the OMNI complete window for the current object/method |
| ysse | creates an ending for the current block. ie: an 'end' or closing brace |
| CTRL-G e | creates an ending for the current block. use in insert mode |
| what to type | what it does |
| :help surround | shows help for the surround plugin |
| CTRL-G = | surrounds the current line with <%= %> |
| CTRL-G CTRL-E | turns the current line into a block <% -%>newline char<% end -%> |
| CTRL-G - | surrounds the current line with <% -%> |
| CTRL-X CTRL-O | brings up the OMNI complete window for the current object/method |
| CTRL-G e | puts an 'end' on the next line |