[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

autoindenting ruby

Martin DeMello

12/15/2007 7:51:00 PM

Something most of the "IDE roundup" threads seem to pass over lightly
is the autoindent feature - for me, that is the make-or-break feature.
How do the various IDEs and editors out there stack up? I'm pretty
happy with gvim and the vim-ruby package, though there are still a few
places where it messes up (yes, I have filed bugs).

martin

9 Answers

forgottenwizard

12/15/2007 8:39:00 PM

0

On 04:51 Sun 16 Dec , Martin DeMello wrote:
> Something most of the "IDE roundup" threads seem to pass over lightly
> is the autoindent feature - for me, that is the make-or-break feature.
> How do the various IDEs and editors out there stack up? I'm pretty
> happy with gvim and the vim-ruby package, though there are still a few
> places where it messes up (yes, I have filed bugs).
>
> martin
>
>

Have you looked into the indent utility? I know it works with C well,
and you can use diffrent "styles" that it comes with. It isn't in an
IDE, but you should be able to run it in a decent IDE.


Martin DeMello

12/15/2007 8:47:00 PM

0

On Dec 16, 2007 2:09 AM, forgottenwizard <phrexianreaper@hushmail.com> wrote:
> Have you looked into the indent utility? I know it works with C well,
> and you can use diffrent "styles" that it comes with. It isn't in an
> IDE, but you should be able to run it in a decent IDE.

That misses the "hit return and have the next line indented properly"
bit that makes vim (and emacs, no doubt) such a pleasure to use.

martin

Vasyl Smirnov

12/15/2007 8:49:00 PM

0

In Emacs I use the following function, found somewhere on the net.

(defun iwb ()
"Indent whole buffer."
(interactive)
(delete-trailing-whitespace)
(indent-region (point-min) (point-max) nil)
(untabify (point-min) (point-max)))

it relies on ruby-mode.el to indent Ruby sources.
Probably something similar can be written/found for vim.

Jari Williamsson

12/15/2007 9:23:00 PM

0

Martin DeMello wrote:
> Something most of the "IDE roundup" threads seem to pass over lightly
> is the autoindent feature - for me, that is the make-or-break feature.
> How do the various IDEs and editors out there stack up? I'm pretty
> happy with gvim and the vim-ruby package, though there are still a few
> places where it messes up (yes, I have filed bugs).

NetBeans 6 has auto-formatting of regions, auto-indenting when pressing
Enter key, different indent settings for start lines and continuations,
option to reformat comment blocks, option to format HTML within RHTML
blocks.

And probably much more. I'm still very much a NB student, learning new
NB tricks every day. Today I learned about autowarn (and auto-fix) for
camelCase variables, or for constants that lacks all-caps, etc. But the
coolest one today was to press Ctrl+Shift+Space (on Windows) when I'm in
a comment, I get an instant RDoc version of that comment block displayed
in a window. Great time saver!


Best regards,

Jari Williamsson

Ryan Davis

12/16/2007 5:40:00 AM

0


On Dec 15, 2007, at 13:12 , Konrad Meyer wrote:

>> (defun iwb ()
>> "Indent whole buffer."
>> (interactive)
>> (delete-trailing-whitespace)
>> (indent-region (point-min) (point-max) nil)
>> (untabify (point-min) (point-max)))
>>
>> it relies on ruby-mode.el to indent Ruby sources.
>> Probably something similar can be written/found for vim.
>
> Yes, the vim for this is very complicated, you have to type "gg=G".

read the code above again and tell me that 'gg=G' does all that...


MonkeeSage

12/16/2007 12:16:00 PM

0

On Dec 15, 11:39 pm, Ryan Davis <ryand-r...@zenspider.com> wrote:
> On Dec 15, 2007, at 13:12 , Konrad Meyer wrote:
>
> >> (defun iwb ()
> >> "Indent whole buffer."
> >> (interactive)
> >> (delete-trailing-whitespace)
> >> (indent-region (point-min) (point-max) nil)
> >> (untabify (point-min) (point-max)))
>
> >> it relies on ruby-mode.el to indent Ruby sources.
> >> Probably something similar can be written/found for vim.
>
> > Yes, the vim for this is very complicated, you have to type "gg=G".
>
> read the code above again and tell me that 'gg=G' does all that...

For vim, that function would be something like...

" Indent whole buffer.
function! IndentFile()
let cursor = line('.')
exe ":%s/\\s\\+$//"
exe "norm gg=G".cursor."G"
exe ":%retab"
endfunction

Regards,
Jordan

Eric Promislow

12/16/2007 7:46:00 PM

0

On Dec 15, 11:51 am, Martin DeMello <martindeme...@gmail.com> wrote:
> Something most of the "IDE roundup" threads seem to pass over lightly
> is the autoindent feature - for me, that is the make-or-break feature.
> How do the various IDEs and editors out there stack up? I'm pretty
> happy with gvim and the vim-ruby package, though there are still a few
> places where it messes up (yes, I have filed bugs).
>
> martin

Komodo does auto-indent for Ruby, including Ruby code in RHTML blocks.

http://www.activestate....

Disclaimer: I'm in charge of the Ruby integration in Komodo.

- Eric

Huw Collingbourne

12/16/2007 9:56:00 PM

0

Ruby In Steel does smart auto-indenting of Ruby and embedded Ruby (in
HTML), also it can reformat an entire document or a marked block to
adjust the code indentation.

http://www.sapphir...

Following Eric's disclaimer (above), I guess I should point out that I
am the Technology Director of Ruby In Steel ;-)

best wishes
Huw
--
Posted via http://www.ruby-....

Reid Thompson

12/16/2007 11:35:00 PM

0

MonkeeSage wrote:
> On Dec 15, 11:39 pm, Ryan Davis <ryand-r...@zenspider.com> wrote:
>> On Dec 15, 2007, at 13:12 , Konrad Meyer wrote:
>>
>>>> (defun iwb ()
>>>> "Indent whole buffer."
>>>> (interactive)
>>>> (delete-trailing-whitespace)
>>>> (indent-region (point-min) (point-max) nil)
>>>> (untabify (point-min) (point-max)))
>>>> it relies on ruby-mode.el to indent Ruby sources.
>>>> Probably something similar can be written/found for vim.
>>> Yes, the vim for this is very complicated, you have to type "gg=G".
>> read the code above again and tell me that 'gg=G' does all that...
>
> For vim, that function would be something like...
>
> " Indent whole buffer.
> function! IndentFile()
> let cursor = line('.')
> exe ":%s/\\s\\+$//"
> exe "norm gg=G".cursor."G"
> exe ":%retab"
> endfunction
>
> Regards,
> Jordan
>
http://vim.wikia.com/wiki/Auto_remove_white_space_w...