# Ruby text editor for beginner

**URL:** <https://rubytalk.org/t/ruby-text-editor-for-beginner/34578>\
**Category:** ruby-talk\
**Created:** [18 January 2007 14:38 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578 "2007-01-18T14:38:00Z")\
**Posts on this page:** 15\
**Page:** 2

<div class="post-metadata">

**Author:** ![Giles\_Bowkett](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@Giles\_Bowkett](https://rubytalk.org/u/Giles_Bowkett)\
**Post date:** [21 January 2007 21:35 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/21 "2007-01-21T21:35:55Z")

</div>

well, if you've installed the gem, I think you can do it just by  
entering a few commands:

# load libraries  
require 'rubygems'  
require 'wirble'

# start wirble (with color)  
Wirble.init  
Wirble.colorize

obviously that's non-optimal, though, because it won't automatically  
load every time. I honestly don't know how irb works on Windows boxes,  
I have one but the irb on it is built into FreeRide or something. you  
can probably use those commands to get started, though.

> **···**
>
> On 1/21/07, bbiker \<renard@nc.rr.com\> wrote:
> 
> > Giles Bowkett wrote:  
> > \> I have a theory about this.  
> > \>  
> > \> My theory is that newbies ask for an IDE because they don't understand irb.  
> > \>  
> > \> If you're a newbie and you want an IDE, my advice is to give it up  
> > \> entirely and instead learn irb.  
> > \>  
> > \> You can get syntax coloring in irb with Wirble, and if you're using  
> > \> Rails, which many many newbies are, script/console is a Rails extended  
> > \> version of irb, which is very very good.  
> > \>
> > 
> > Question: How do you use wirble with win32 machine?  
> > The wirble documentation talks about .irbrc file which obviously I do  
> > not have
> > 
> > ruby 1.8.5 (2006-08-25) [i386-mswin32]  
> > irb 0.9.5(05/04/13)
> > 
> > Thank you for any assistance you may offer.
> 
> --  
> Giles Bowkett  
> [http://www.gilesgoatboy.org](http://www.gilesgoatboy.org)
> 
> > **[Giles Bowkett](http://gilesbowkett.blogspot.com)**
> >
> > half-disavowed old blog. new blog at gilesbowkett.com
> 
> [http://gilesgoatboy.blogspot.com](http://gilesgoatboy.blogspot.com)

---

<div class="post-metadata">

**Author:** ![Wilson\_Bilkovich](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/wilson_bilkovich/32/8247_2.png) [@Wilson\_Bilkovich](https://rubytalk.org/u/Wilson_Bilkovich)\
**Post date:** [21 January 2007 21:36 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/22 "2007-01-21T21:36:06Z")

</div>

You can't. Not because you can't have a .irbrc file (You just need to  
specify a directory in the HOME environment variable, and put it  
there).. but because Microsoft got rid of color support in the command  
prompt.  
You could disable color in wirble and make it work though, I suspect.

> **···**
>
> On 1/21/07, bbiker \<renard@nc.rr.com\> wrote:
> 
> > Giles Bowkett wrote:  
> > \> I have a theory about this.  
> > \>  
> > \> My theory is that newbies ask for an IDE because they don't understand irb.  
> > \>  
> > \> If you're a newbie and you want an IDE, my advice is to give it up  
> > \> entirely and instead learn irb.  
> > \>  
> > \> You can get syntax coloring in irb with Wirble, and if you're using  
> > \> Rails, which many many newbies are, script/console is a Rails extended  
> > \> version of irb, which is very very good.  
> > \>
> > 
> > Question: How do you use wirble with win32 machine?  
> > The wirble documentation talks about .irbrc file which obviously I do  
> > not have
> > 
> > ruby 1.8.5 (2006-08-25) [i386-mswin32]  
> > irb 0.9.5(05/04/13)

---

<div class="post-metadata">

**Author:** ![Helder\_Ribeiro](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@Helder\_Ribeiro](https://rubytalk.org/u/Helder_Ribeiro)\
**Post date:** [22 January 2007 02:20 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/23 "2007-01-22T02:20:07Z")

</div>

Jonathan Allen wrote:

> I'm willing to bet that most of them don't understand how to effectively  
> use a REPL loop, and that's fine if you look at it from their  
> perspective.

That's exactly right. I'm good using REPL for simple scripting, but I  
can't think of a good way to use it for bigger things. Could you point  
me (us) out some reading on how to use it for serious development?

> There is also the familiarity aspects. People coming from a non-REPL  
> background often look at it and ask, "Ok, now how do I save my program?"  
> or "Do I really have to retype my last 30 lines to fix that little bug  
> in method foo?".

Those are the very first questions that come to my mind, indeed. What  
are the answers?

Cheers,

Helder

---

<div class="post-metadata">

**Author:** ![dean1](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@dean1](https://rubytalk.org/u/dean1)\
**Post date:** [21 January 2007 21:56 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/24 "2007-01-21T21:56:52Z")

</div>

you can InType [http://intype.info/home/index.php](http://intype.info/home/index.php)  
is still in alpha but is has lots of the funcionality of texmate

cheers,  
d

> **···**
>
> On 1/21/07, Wilson Bilkovich \<wilsonb@gmail.com\> wrote:
> 
> > On 1/21/07, bbiker \<renard@nc.rr.com\> wrote:  
> > \> Giles Bowkett wrote:  
> > \> \> I have a theory about this.  
> > \> \>  
> > \> \> My theory is that newbies ask for an IDE because they don't understand  
> > irb.  
> > \> \>  
> > \> \> If you're a newbie and you want an IDE, my advice is to give it up  
> > \> \> entirely and instead learn irb.  
> > \> \>  
> > \> \> You can get syntax coloring in irb with Wirble, and if you're using  
> > \> \> Rails, which many many newbies are, script/console is a Rails extended  
> > \> \> version of irb, which is very very good.  
> > \> \>  
> > \>  
> > \> Question: How do you use wirble with win32 machine?  
> > \> The wirble documentation talks about .irbrc file which obviously I do  
> > \> not have  
> > \>  
> > \> ruby 1.8.5 (2006-08-25) [i386-mswin32]  
> > \> irb 0.9.5(05/04/13)  
> > \>
> > 
> > You can't. Not because you can't have a .irbrc file (You just need to  
> > specify a directory in the HOME environment variable, and put it  
> > there).. but because Microsoft got rid of color support in the command  
> > prompt.  
> > You could disable color in wirble and make it work though, I suspect.

---

<div class="post-metadata">

**Author:** ![James\_Edward\_Gray\_II](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@James\_Edward\_Gray\_II](https://rubytalk.org/u/James_Edward_Gray_II)\
**Post date:** [22 January 2007 03:08 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/25 "2007-01-22T03:08:11Z")

</div>

A big project is just a ton of little projects, once you chop it up. Test driven development is all about that, I think.

James Edward Gray II

> **···**
>
> On Jan 21, 2007, at 8:20 PM, Helder Ribeiro wrote:
> 
> > Jonathan Allen wrote:
> > 
> > > I'm willing to bet that most of them don't understand how to effectively  
> > > use a REPL loop, and that's fine if you look at it from their  
> > > perspective.
> > 
> > That's exactly right. I'm good using REPL for simple scripting, but I  
> > can't think of a good way to use it for bigger things. Could you point  
> > me (us) out some reading on how to use it for serious development?

---

<div class="post-metadata">

**Author:** ![Helder\_Ribeiro](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@Helder\_Ribeiro](https://rubytalk.org/u/Helder_Ribeiro)\
**Post date:** [22 January 2007 11:48 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/26 "2007-01-22T11:48:59Z")

</div>

James Edward Gray II wrote:

> A big project is just a ton of little projects, once you chop it up.  
> Test driven development is all about that, I think.

Yes, but sometimes you can't chop it up so fine-grained that you have  
self-contained, one-lined commands (that's what I meant by  
'scripting').

Say you write up a method and want to correct it, you have retype or  
find through the history by pressing "Up" all the lines that "worked"  
and re-entering them. You also can't just read them from a file either,  
AFAIK (not smthg like an incomplete method code, for instance).

Conversely, it's not trivial to go through the lines that "worked" in  
that awkward "Up"-key fashion, then select them and save them out to a  
file.

Those are the questions Jonathan Allen pointed out, and I don't have  
good answers for them.

Perhaps there's some different mode in irb where you can quickly  
inspect the aggregated command history as in a regular editor and  
choose to append selected lines out to a file? That'd be very helpful,  
especially with the ability to load them back as if you had typed them  
in yourself, which would allow for loading of incomplete blocks of  
code.

> **···**
>
> > On Jan 21, 2007, at 8:20 PM, Helder Ribeiro wrote:
> 
> > James Edward Gray II

---

<div class="post-metadata">

**Author:** ![M\_Edward\_Ed\_Borasky1](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@M\_Edward\_Ed\_Borasky1](https://rubytalk.org/u/M_Edward_Ed_Borasky1)\
**Post date:** [22 January 2007 14:59 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/27 "2007-01-22T14:59:11Z")

</div>

James Edward Gray II wrote:

> > That's exactly right. I'm good using REPL for simple scripting, but I  
> > can't think of a good way to use it for bigger things. Could you point  
> > me (us) out some reading on how to use it for serious development?
> 
> A big project is just a ton of little projects, once you chop it up. Test driven development is all about that, I think.
> 
> James Edward Gray II

Uh ... not really, for a number of reasons. To use the old saw about nine women not being able to produce a baby in one month, a baby is not a collection of small separately-developed pieces. A large software project is a complex adaptive system, interacting with numerous machines, users, creators and maintainers in many different ways. One distinguishing characteristic of complex adaptive systems is that they exhibit behavior that \*can't\* be explained or predicted by examining their components. Just like the baby, there are pieces you can remove that degrade their functioning, pieces like hair and toenails that return if removed (log files, for example 🙂 ) and pieces you can't remove without destroying their functioning.

Irb-style "design-at-the-keyboard" doesn't scale beyond a small, "agile" project. I'm not sure test-driven development or continuous refactoring do, either, because nobody has ever to my knowledge had the budget to attempt it -- we're all too busy on the next "complex adaptive software project that's good enough". 🙂 Irb is \*part\* of the tool set you need to work on a complex adaptive Ruby software project. I can't imagine working on such a project without irb. But if text-based tools are \*all\* I'm allowed to work with, I'd seriously question my relationship with management. 🙂

> **···**
>
> > On Jan 21, 2007, at 8:20 PM, Helder Ribeiro wrote:
> 
> --  
> M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)  
> [http://borasky-research.blogspot.com/](http://borasky-research.blogspot.com/)
> 
> If God had meant for carrots to be eaten cooked, He would have given rabbits fire.

---

<div class="post-metadata">

**Author:** ![Randy\_Kramer](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Randy\_Kramer](https://rubytalk.org/u/Randy_Kramer)\
**Post date:** [22 January 2007 13:16 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/28 "2007-01-22T13:16:32Z")

</div>

I am not a very experienced Ruby programmer, but what I find helps in that  
regard is that I do my irb work in a kde konsole. It displays all the old  
lines that I've entered (and results) with its "History" feature. I then  
use Linux style copy (select then paste with middle mouse button) to grab the  
lines I want, paste them into my editor, and edit out the stuff I don't want  
(if I've copied more than I want).

Randy Kramer

> **···**
>
> On Monday 22 January 2007 06:48 am, Helder Ribeiro wrote:
> 
> > Say you write up a method and want to correct it, you have retype or  
> > find through the history by pressing "Up" all the lines that "worked"  
> > and re-entering them. You also can't just read them from a file either,  
> > AFAIK (not smthg like an incomplete method code, for instance).
> > 
> > Conversely, it's not trivial to go through the lines that "worked" in  
> > that awkward "Up"-key fashion, then select them and save them out to a  
> > file.
> > 
> > Those are the questions Jonathan Allen pointed out, and I don't have  
> > good answers for them.
> > 
> > Perhaps there's some different mode in irb where you can quickly  
> > inspect the aggregated command history as in a regular editor and  
> > choose to append selected lines out to a file? That'd be very helpful,  
> > especially with the ability to load them back as if you had typed them  
> > in yourself, which would allow for loading of incomplete blocks of  
> > code.

---

<div class="post-metadata">

**Author:** ![James\_Edward\_Gray\_II](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@James\_Edward\_Gray\_II](https://rubytalk.org/u/James_Edward_Gray_II)\
**Post date:** [22 January 2007 13:55 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/29 "2007-01-22T13:55:52Z")

</div>

> Yes, but sometimes you can't chop it up so fine-grained that you have  
> self-contained, one-lined commands (that's what I meant by  
> 'scripting').

I think it's harder for some projects than others, but I'm not willing to go all the way to "can't". 😉

> Say you write up a method and want to correct it, you have retype or  
> find through the history by pressing "Up" all the lines that "worked"  
> and re-entering them. You also can't just read them from a file either,  
> AFAIK (not smthg like an incomplete method code, for instance).
> 
> Conversely, it's not trivial to go through the lines that "worked" in  
> that awkward "Up"-key fashion, then select them and save them out to a  
> file.

Here are some ideas:

\>\> def test  
\>\> puts "This line is OK."  
\>\> puts "So is this one."  
\>\> Object.new.no\_such\_method # Oops!  
\>\> end  
=\> nil  
\>\> test  
This line is OK.  
So is this one.  
NoMethodError: undefined method `no\_such\_method' for #\<Object:0x102f9ac\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):4:in `test'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):6  
\>\> h 6  
[0758] def test  
[0759] puts "This line is OK."  
[0760] puts "So is this one."  
[0761] Object.new.no\_such\_method # Oops!  
[0762] end  
[0763] test  
[0764] h 6  
=\> nil  
\>\> get\_lines(758..760) \<\< "puts 'Now this is better.'" \<\< "end"  
=\> ["def test", " puts "This line is OK."", " puts "So is this one."", "puts 'Now this is better.'", "end"]  
\>\> eval((get\_lines(758..760) \<\< "puts 'Now this is better.'" \<\< "end").join("\n"))  
=\> nil  
\>\> test  
This line is OK.  
So is this one.  
Now this is better.  
=\> nil

You can also write to a file:

\>\> hw "test\_method.rb", 758..760  
=\> nil  
\>\> File.read("test\_method.rb")  
=\> "def test\n puts "This line is OK."\n puts "So is this one."\n"  
\>\> File.open("test\_method.rb", "a") { |f| f \<\< " puts 'Fixed in the file.'\nend\n" }  
=\> #\<File:test\_method.rb (closed)\>  
\>\> File.read("test\_method.rb")=\> "def test\n puts "This line is OK."\n puts "So is this one."\n puts 'Fixed in the file.'\nend\n"  
\>\> load "test\_method.rb"  
=\> true  
\>\> test  
This line is OK.  
So is this one.  
Fixed in the file.  
=\> nil

The methods I am using here come from:

[http://blog.bleything.net/pages/irb\_history](http://blog.bleything.net/pages/irb_history)

Hope that helps.

James Edward Gray II

> **···**
>
> On Jan 22, 2007, at 5:48 AM, Helder Ribeiro wrote:

---

<div class="post-metadata">

**Author:** ![James\_Edward\_Gray\_II](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@James\_Edward\_Gray\_II](https://rubytalk.org/u/James_Edward_Gray_II)\
**Post date:** [22 January 2007 15:10 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/30 "2007-01-22T15:10:16Z")

</div>

> **[Test-Driven Development in Large Projects](https://ieeexplore.ieee.org/document/1717338/;jsessionid=TRmbgDe3PuuTi-lFT0WzliU8kB9IcRrbNoxYRP-1gdf79anZQ4dW!1188849748?isnumber=36124&arnumber=1717338&count=20&index=7)**
>
> Test-driven development (TDD) is a key practice for agile developers because it involves writing test cases ahead of the code, which can improve design. The TDD process works well for projects in which a collocated team develops a small to medium...

James Edward Gray II

> **···**
>
> On Jan 22, 2007, at 8:59 AM, M. Edward (Ed) Borasky wrote:
> 
> > Irb-style "design-at-the-keyboard" doesn't scale beyond a small, "agile" project. I'm not sure test-driven development or continuous refactoring do, either, because nobody has ever to my knowledge had the budget to attempt it

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://rubytalk.org/u/Martin_DeMello)\
**Post date:** [23 January 2007 08:15 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/31 "2007-01-23T08:15:06Z")

</div>

It's on the to-do list for fxirb. I already have multiline history working:

> **···**
>
> On 1/22/07, Helder Ribeiro \<helder@gmail.com\> wrote:
> 
> > Conversely, it's not trivial to go through the lines that "worked" in  
> > that awkward "Up"-key fashion, then select them and save them out to a  
> > file.
> 
> ----------------------------------------------------------------  
> irb(main):001:0\> [1,2,3,4,5].each {|a|  
> irb(main):002:1\* b = a + 2  
> irb(main):003:1\> puts b  
> irb(main):004:1\> }  
> 3  
> 4  
> 5  
> 6  
> 7  
> =\> [1, 2, 3, 4, 5]  
> irb(main):005:0\> [1,2,3,4,5].each {|a|  
> b = a + 2  
> puts b  
> &nbsp;&nbsp;}
> 
> ----------------------------------------------------------------
> 
> all I need to do is add various session and entry save options. Some  
> sort of mathematica-like system would be nice.
> 
> martin

---

<div class="post-metadata">

**Author:** ![M\_Edward\_Ed\_Borasky1](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@M\_Edward\_Ed\_Borasky1](https://rubytalk.org/u/M_Edward_Ed_Borasky1)\
**Post date:** [23 January 2007 03:31 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/32 "2007-01-23T03:31:27Z")

</div>

James Edward Gray II wrote:

> > Irb-style "design-at-the-keyboard" doesn't scale beyond a small, "agile" project. I'm not sure test-driven development or continuous refactoring do, either, because nobody has ever to my knowledge had the budget to attempt it
> 
> [Test-Driven Development in Large Projects | IEEE Journals & Magazine | IEEE Xplore](http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?isnumber=36124&arnumber=1717338&count=20&index=7)
> 
> James Edward Gray II

Thanks!! If I run out of queuing theory papers to buy, I might buy that one. 🙂 However:

"the coordination and communication grows exponentially with the number of individual developers and sites. "

That's not correct, either. The formula \*involves\* exponentials, but the communication and coordination does not grow exponentially -- nothing large could be built if it did. I have the formulas somewhere; if I can find them, I'll post them here.

> **···**
>
> > On Jan 22, 2007, at 8:59 AM, M. Edward (Ed) Borasky wrote:
> 
> --  
> M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)  
> [http://borasky-research.blogspot.com/](http://borasky-research.blogspot.com/)
> 
> If God had meant for carrots to be eaten cooked, He would have given rabbits fire.

---

<div class="post-metadata">

**Author:** ![Helder\_Ribeiro](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@Helder\_Ribeiro](https://rubytalk.org/u/Helder_Ribeiro)\
**Post date:** [23 January 2007 23:20 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/33 "2007-01-23T23:20:09Z")

</div>

Hey, great idea! I'm so used to the default mode using bash that I had  
never noticed I could use irb from \*inside\* konsole. I always ran it  
from bash. I'll try that out see how it works!

Thanks a lot!

Helder Ribeiro

> **···**
>
> On Jan 22, 11:16 am, Randy Kramer \<rhkra...@gmail.com\> wrote:
> 
> > I am not a very experienced Ruby programmer, but what I find helps in that  
> > regard is that I do my irb work in a kde konsole. It displays all the old  
> > lines that I've entered (and results) with its "History" feature. I then  
> > use Linux style copy (select then paste with middle mouse button) to grab the  
> > lines I want, paste them into my editor, and edit out the stuff I don't want  
> > (if I've copied more than I want).

---

<div class="post-metadata">

**Author:** ![Helder\_Ribeiro](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@Helder\_Ribeiro](https://rubytalk.org/u/Helder_Ribeiro)\
**Post date:** [23 January 2007 23:25 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/34 "2007-01-23T23:25:06Z")

</div>

Wow, this is awesome! The language is introspective and so is the REPL  
=) I'll see how I get along with that. Thanks a lot!

Helder Ribeiro

> **···**
>
> On Jan 22, 11:55 am, James Edward Gray II \<j...@grayproductions.net\> wrote:
> 
> > On Jan 22, 2007, at 5:48 AM,HelderRibeirowrote:
> > 
> > \> Yes, but sometimes you can't chop it up so fine-grained that you have  
> > \> self-contained, one-lined commands (that's what I meant by  
> > \> 'scripting').I think it's harder for some projects than others, but I'm not  
> > willing to go all the way to "can't". 😉
> > 
> > \> Say you write up a method and want to correct it, you have retype or  
> > \> find through the history by pressing "Up" all the lines that "worked"  
> > \> and re-entering them. You also can't just read them from a file  
> > \> either,  
> > \> AFAIK (not smthg like an incomplete method code, for instance).
> > 
> > \> Conversely, it's not trivial to go through the lines that "worked" in  
> > \> that awkward "Up"-key fashion, then select them and save them out to a  
> > \> file.Here are some ideas:
> > 
> > \>\> def test  
> > \>\> puts "This line is OK."  
> > \>\> puts "So is this one."  
> > \>\> Object.new.no\_such\_method # Oops!  
> > \>\> end  
> > =\> nil  
> > \>\> test  
> > This line is OK.  
> > So is this one.  
> > NoMethodError: undefined method `no\_such\_method' for #\<Object:0x102f9ac\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):4:in `test'  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):6  
> > \>\> h 6  
> > [0758] def test  
> > [0759] puts "This line is OK."  
> > [0760] puts "So is this one."  
> > [0761] Object.new.no\_such\_method # Oops!  
> > [0762] end  
> > [0763] test  
> > [0764] h 6  
> > =\> nil  
> > \>\> get\_lines(758..760) \<\< "puts 'Now this is better.'" \<\< "end"  
> > =\> ["def test", " puts "This line is OK."", " puts "So is this  
> > one."", "puts 'Now this is better.'", "end"]  
> > \>\> eval((get\_lines(758..760) \<\< "puts 'Now this is better.'" \<\<  
> > "end").join("\n"))  
> > =\> nil  
> > \>\> test  
> > This line is OK.  
> > So is this one.  
> > Now this is better.  
> > =\> nil
> > 
> > You can also write to a file:
> > 
> > \>\> hw "test\_method.rb", 758..760  
> > =\> nil  
> > \>\> File.read("test\_method.rb")  
> > =\> "def test\n puts "This line is OK."\n puts "So is this one."\n"  
> > \>\> File.open("test\_method.rb", "a") { |f| f \<\< " puts 'Fixed in the  
> > file.'\nend\n" }  
> > =\> #\<File:test\_method.rb (closed)\>  
> > \>\> File.read("test\_method.rb")=\> "def test\n puts "This line is  
> > OK."\n puts "So is this one."\n puts 'Fixed in the file.'\nend\n"  
> > \>\> load "test\_method.rb"  
> > =\> true  
> > \>\> test  
> > This line is OK.  
> > So is this one.  
> > Fixed in the file.  
> > =\> nil
> > 
> > The methods I am using here come from:
> > 
> > [http://blog.bleything.net/pages/irb\_history](http://blog.bleything.net/pages/irb_history)
> > 
> > Hope that helps.

---

<div class="post-metadata">

**Author:** ![Randy\_Kramer](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Randy\_Kramer](https://rubytalk.org/u/Randy_Kramer)\
**Post date:** [25 January 2007 00:25 UTC](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578/35 "2007-01-25T00:25:21Z")

</div>

You're welcome--hope it helps!

Randy Kramer

> **···**
>
> On Tuesday 23 January 2007 06:20 pm, Helder Ribeiro wrote:
> 
> > Hey, great idea! I'm so used to the default mode using bash that I had  
> > never noticed I could use irb from \*inside\* konsole. I always ran it  
> > from bash. I'll try that out see how it works!
> > 
> > Thanks a lot!

[Previous page](https://rubytalk.org/t/ruby-text-editor-for-beginner/34578.md?page=1)
