insert result of ruby

Tim Hammerquist penryu at
Wed Dec 21 03:05:14 EST 2005

Jeff Rose wrote:
> Anyone know if there is a way to run a small bit of ruby and
> insert the result into the current buffer?
> I wanted to do something like this, but get the output into
> the buffer rather than the command window:
> :ruby require 'date'; puts

Assuming you have a vim built with +ruby:

:ruby <<EOF
def insert_string (str)
    buf = VIM::Buffer.current
    win = VIM::Window.current
    buf.append(win.cursor[0], str)

:ruby require 'date'; insert_string( )

Tim Hammerquist
Show me something that beats a Natural Twenty,
and I'll show you hateful LIES!
    -- Red Mage, 8-Bit Theater <>

More information about the vim-ruby-devel mailing list