Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby syntax checking in vim

I use vim with various plugins for editing ruby code. I have proper syntax highlighting set up but I was wondering if anyone knew of a way to get ruby syntax checking, similar to what you might see in an IDE such as visual studio, radrails, etc?

Something that would simply turn stuff red or break highlighting when I'm missing an 'end' or have an improperly constructed line of code would be sweet.

I googled and came across this plugin, http://github.com/scrooloose/syntastic/tree/master but I was wondering if anyone had any better suggestions.

like image 523
roydq Avatar asked Aug 19 '09 20:08

roydq


2 Answers

You can syntax check the current buffer in ruby without downloading any plugins. The command is:

:w !ruby -c
like image 91
awesome_person Avatar answered Oct 07 '22 19:10

awesome_person


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.

like image 35
Adam Libuša Avatar answered Oct 07 '22 17:10

Adam Libuša