Reputation: 3115
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!
Upvotes: 9
Views: 5857
Reputation: 1896
ruby-runner is a vim plugin that allows you to run ruby script from within vim, the good part is you can see your code output along with the your code at the same time.
https://github.com/henrik/vim-ruby-runner
Upvotes: 0
Reputation: 5947
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
Upvotes: 7
Reputation: 8119
Use the :!<anything want bash or the calling shell of vim to execute>
. So if you have a script named foo.rb
, to execute it from within the vim editor call :!ruby foo.rb
.
Upvotes: 1
Reputation: 124429
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.
Upvotes: 20
Reputation: 70562
Well, one simple thing you can use is to execute a command in your shell with :!
.
# Typing typing typing...
# Oh! Gotta commit.
:!hg ci -m "Add awesome module xyz"
Or you can use :shell
to drop into the shell, if you're going to be doing more complex things.
Upvotes: 1