# IRB : Auto\_Indent in Windows

**URL:** <https://www.ruby-forum.com/t/irb-auto-indent-in-windows/124432>\
**Category:** Ruby\
**Created:** [December 28, 2007, 5:24pm UTC](https://www.ruby-forum.com/t/irb-auto-indent-in-windows/124432 "2007-12-28T17:24:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e9bcb4/32.png) [@kena](https://www.ruby-forum.com/u/kena)\
**Post date:** [December 28, 2007, 5:24pm UTC](https://www.ruby-forum.com/t/irb-auto-indent-in-windows/124432/1 "2007-12-28T17:24:09Z")

</div>

Hi. I managed to set auto\_indent, but it just don’t work quite the way  
we expect, at least in Windows. eg, in irb console I type:

def my\_method  
a = “some text”  
end

but I need (visually speaking)

def my\_method  
a = “some text”  
end

Can I fix it? or it’s a limitation on Windows?

---

<div class="post-metadata">

**Author:** ![kena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e9bcb4/32.png) [@kena](https://www.ruby-forum.com/u/kena)\
**Post date:** [December 28, 2007, 5:32pm UTC](https://www.ruby-forum.com/t/irb-auto-indent-in-windows/124432/2 "2007-12-28T17:32:54Z")

</div>

> Hi. I managed to set auto\_indent, but it just don’t work quite the way  
> we expect…  
> Can I fix it? or it’s a limitation on Windows?

It’s a limitation of IRB. If you find a fix, though, that would be  
very very cool.

–  
Giles B.

Podcast: [http://hollywoodgrit.blogspot.com](http://hollywoodgrit.blogspot.com)  
Blog: [http://gilesbowkett.blogspot.com](http://gilesbowkett.blogspot.com)  
Portfolio: [http://www.gilesgoatboy.org](http://www.gilesgoatboy.org)  
Tumblelog: [http://giles.tumblr.com](http://giles.tumblr.com)

---

<div class="post-metadata">

**Author:** ![kena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e9bcb4/32.png) [@kena](https://www.ruby-forum.com/u/kena)\
**Post date:** [December 28, 2007, 5:53pm UTC](https://www.ruby-forum.com/t/irb-auto-indent-in-windows/124432/3 "2007-12-28T17:53:24Z")

</div>

It would need to re-write the line after the \n, which requires going  
up a line and re-writing.  
or… it would require not echoing keys to the terminal.

Neither are easy to support on windows due to bugs and limitations in  
the curses and readline implementations, although I expect with some  
added complexity to irb (unless it’s already there of course), this  
could be done quite trivially on \*nix systems.

---

<div class="post-metadata">

**Author:** ![kena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e9bcb4/32.png) [@kena](https://www.ruby-forum.com/u/kena)\
**Post date:** [December 28, 2007, 6:25pm UTC](https://www.ruby-forum.com/t/irb-auto-indent-in-windows/124432/4 "2007-12-28T18:25:38Z")

</div>

On Dec 28, 1:24 pm, “Ken A.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> a = “some text”  
> end
> 
> Can I fix it? or it’s a limitation on Windows?

No, is a IRB limitation.

There is no way “in advance” that IRB understand that you’re doing  
‘end’ and it should be indented one level lower than previous  
indentantion.

IF tricky, adding something like that can create problems with users  
just doing:

def foo; “bar”; end

and IRB trying “as you time” to reindent the code…

I’ll suggest you code in some IDE, like Komodo or NetBeans that  
automatically indent your code.

HTH,

Luis

---

<div class="post-metadata">

**Author:** ![kena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e9bcb4/32.png) [@kena](https://www.ruby-forum.com/u/kena)\
**Post date:** [December 28, 2007, 11:02pm UTC](https://www.ruby-forum.com/t/irb-auto-indent-in-windows/124432/5 "2007-12-28T23:02:33Z")

</div>

> I expect with some  
> added complexity to irb (unless it’s already there of course), this  
> could be done quite trivially on \*nix systems.

Triviality is a relative term. I don’t have the faintest idea where to  
start on something like that but I would be thrilled to figure it out.  
I’d throw it into my IRB enhancements gem quicker than the Flash plus  
Red Bull. I think IRB just drops its output into STDOUT, so  
repositioning it after the fact sounds pretty challenging. Would it  
just be something to regex the output before dumping to STDOUT? I  
think currently all the auto-indentation is handled by modifying the  
prompt.

–  
Giles B.

Podcast: [http://hollywoodgrit.blogspot.com](http://hollywoodgrit.blogspot.com)  
Blog: [http://gilesbowkett.blogspot.com](http://gilesbowkett.blogspot.com)  
Portfolio: [http://www.gilesgoatboy.org](http://www.gilesgoatboy.org)  
Tumblelog: [http://giles.tumblr.com](http://giles.tumblr.com)
