# VIM and IRB

**URL:** <https://www.ruby-forum.com/t/vim-and-irb/103467>\
**Category:** Ruby\
**Created:** [May 6, 2007, 4:05pm UTC](https://www.ruby-forum.com/t/vim-and-irb/103467 "2007-05-06T16:05:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lobbr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/aeb1de/32.png) [@lobbr](https://www.ruby-forum.com/u/lobbr)\
**Post date:** [May 6, 2007, 4:05pm UTC](https://www.ruby-forum.com/t/vim-and-irb/103467/1 "2007-05-06T16:05:41Z")

</div>

Hi,

my favourite editor for programming is Vim. When editing some  
ruby-scripts I  
usually have an xterm open with a running irb-session. When testing some  
code snippets, I copy & paste them to IRB. In Emacs I could evaluate  
those  
snippets in an inferior-ruby session within Emacs. I do not know how to  
this in Vim, so I wrote a little vim-plugin called ‘vinfruby’ to do  
something similar.

vinfruby starts an xterm with an IRB session and uses DRb to communicate  
with the Vim-plugin. The plugin then sends the code to be evaluated on  
keypress to IRB, for example just press ‘\rt’ to open an irb session,  
‘\rf’  
to send the whole file to irb or ‘\rd’ to send the current ‘def…end’  
block.

I do not know, but perhaps someone may find this script useful so I  
decided  
to post it here in the news. Just extract the files from

[http://www-user.tu-chemnitz.de/~fifr/downloads/vinfruby.tgz](http://www-user.tu-chemnitz.de/~fifr/downloads/vinfruby.tgz)

to ~/.vim/plugin. The file ‘vinfruby.vim’ explains the key-mappings. The  
plugin is neighter complete nor pretty well tested, but it works for me.

Hope it may be useful,

Greetings,

Frank.

---

<div class="post-metadata">

**Author:** ![lobbr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/aeb1de/32.png) [@lobbr](https://www.ruby-forum.com/u/lobbr)\
**Post date:** [May 6, 2007, 5:37pm UTC](https://www.ruby-forum.com/t/vim-and-irb/103467/2 "2007-05-06T17:37:48Z")

</div>

On 5/6/07, Frank F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> with the Vim-plugin. The plugin then sends the code to be evaluated on  
> plugin is neighter complete nor pretty well tested, but it works for me.
> 
> Hope it may be useful,

Nice, this may become my new favorite toy. Thanks!

---

<div class="post-metadata">

**Author:** ![lobbr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/aeb1de/32.png) [@lobbr](https://www.ruby-forum.com/u/lobbr)\
**Post date:** [May 6, 2007, 7:08pm UTC](https://www.ruby-forum.com/t/vim-and-irb/103467/3 "2007-05-06T19:08:57Z")

</div>

On 5/6/07, Frank F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> with the Vim-plugin. The plugin then sends the code to be evaluated on  
> plugin is neighter complete nor pretty well tested, but it works for me.
> 
> Hope it may be useful,
> 
> Greetings,
> 
> Frank.

Much simpler but not nearly as cool, and I don’t know if others do the  
same, I have my vim set up to save and run the current file in IRB  
when I hit F2 (doesn’t work in gvim):

map :!clear:w:!irb -r%

Brian

---

<div class="post-metadata">

**Author:** ![lobbr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/aeb1de/32.png) [@lobbr](https://www.ruby-forum.com/u/lobbr)\
**Post date:** [May 8, 2007, 12:15am UTC](https://www.ruby-forum.com/t/vim-and-irb/103467/4 "2007-05-08T00:15:22Z")

</div>

I’m looking into his script above… but even your script is a  
lifesaver! I  
use vim almost exclusively (although the new Netbeans stuff is  
tempting…)  
but getting my code into irb has often been a pain for me. Thanks for  
the  
script!

–Tyler P.
