insert result of ruby

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

insert result of ruby

Jeff Rose-3
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
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: insert result of ruby

Ryan Platte-5
This should get you started:

:help r!

On 12/20/05, Jeff Rose <[hidden email]> 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
> [hidden email]
> http://rubyforge.org/mailman/listinfo/vim-ruby-devel
>
>


--
Ryan Platte

_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: insert result of ruby

Jeffrey Dik
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 <[hidden email]> 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
> > [hidden email]
> > http://rubyforge.org/mailman/listinfo/vim-ruby-devel
> >
> >
>
>
> --
> Ryan Platte
>
> _______________________________________________
> vim-ruby-devel mailing list
> [hidden email]
> http://rubyforge.org/mailman/listinfo/vim-ruby-devel
>
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: insert result of ruby

Tim Hammerquist-3
In reply to this post by Jeff Rose-3
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/>
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: insert result of ruby

Tim Hammerquist-3
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
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel