Ruby syntax checking in vim
You can syntax check the current buffer in ruby without downloading any plugins. The command is:
:w !ruby -c
awesome_person is right, ":w !ruby -c"
will do. To make it more convenient, add this line in your ~/.vimrc:
autocmd FileType ruby map <F9> :w<CR>:!ruby -c %<CR>
Then the syntax gets checked on pressing F9 key.
I think the existing answers are outdated. A ruby compiler plugin comes with vim now, so all you should need to do now is run :compiler ruby
, or add this command to your ~/.vim/ftplugin/ruby.vim
file (creating it if necessary). Then, not only will running :make
syntax check your code, it will put you in vim quickfix mode, enabling you to jump directly to errors.
I say "should" because the compiler plugin misses the point a bit and doesn't set makeprg
sensibly. Here is what I actually put in ~/.vim/ftplugin/ruby.vim
:
compiler rubysetlocal makeprg=ruby\ -wc\ %
I suggested that this be the default.