Jeff Rose | 20 Dec 23:17

insert result of ruby

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 Date.today

-Jeff
Ryan Platte | 20 Dec 23:34
Favicon

Re: insert result of ruby

This should get you started:

:help r!

On 12/20/05, Jeff Rose <rosejn <at> gmail.com> 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 Date.today
>
> -Jeff
>
> _______________________________________________
> vim-ruby-devel mailing list
> vim-ruby-devel <at> rubyforge.org
> http://rubyforge.org/mailman/listinfo/vim-ruby-devel
>
>

--
Ryan Platte
Jeffrey Dik | 20 Dec 23:59

Re: insert result of ruby

For another approach, check out

http://eigenclass.org/hiki.rb?Ruby+support+for+Vim
http://www.rubygarden.org/ruby?VimXmp
http://www.rubygarden.org/ruby?VimExtensions

Hope that helps,
Jeff

On Tue, Dec 20, 2005 at 04:34:51PM -0600, Ryan Platte wrote:
> This should get you started:
> 
> :help r!
> 
> On 12/20/05, Jeff Rose <rosejn <at> gmail.com> 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 Date.today
> >
> > -Jeff
> >
> > _______________________________________________
> > vim-ruby-devel mailing list
> > vim-ruby-devel <at> rubyforge.org
> > http://rubyforge.org/mailman/listinfo/vim-ruby-devel
> >
(Continue reading)

Tim Hammerquist | 21 Dec 09:05

Re: insert result of ruby

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 Date.today

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)
end
EOF

:ruby require 'date'; insert_string( Date.today.to_s )

HTH,
Tim Hammerquist
--

-- 
Show me something that beats a Natural Twenty,
and I'll show you hateful LIES!
    -- Red Mage, 8-Bit Theater <http://nuklearpower.com/>
Tim Hammerquist | 21 Dec 09:07

Re: insert result of ruby

Tim Hammerquist wrote:
> 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 Date.today
> 
> 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)
> end
> EOF
> 
> :ruby require 'date'; insert_string( Date.today.to_s )

Doh!

:help if_ruby

for more information. :)

Tim
(Continue reading)


Gmane