Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute Code in VIM similar to Cmd+R in Textmate or Cmd+B Sublime Text2

Hey is there a way or plugin to execute Code e.g. Ruby in my case, directly from my vim editor. I know this from Textmate, where you can execute Code with Cmd+R or Cmd+B in Sublime Text2. In Sublime Text it is called Build System. Thanks for advise!

like image 613
daniel Avatar asked Feb 14 '12 20:02

daniel


2 Answers

If you just want to execute the current buffer in Ruby, you could do this in normal mode:

:!ruby %

You could also map that to a shortcut with your leader key:

:map <leader>r :!ruby %<cr>

Which would let you do leader+r to run the file.

like image 54
Dylan Markow Avatar answered Sep 18 '22 19:09

Dylan Markow


My vim has a :rubydo command, select the section of code you want to execute (or nothing to execute the whole buffer), and do

:rubydo

"'<,'>" will be added automatically after ":" if something was selected.

that should to the trick

like image 34
Tshirtman Avatar answered Sep 17 '22 19:09

Tshirtman