Autoindenting ruby

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

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.

On Dec 16, 2007 2:09 AM, forgottenwizard [email protected]
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

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.

Quoth Vasyl S.:

Probably something similar can be written/found for vim.
Yes, the vim for this is very complicated, you have to type “gg=G”.

Regards,

On Dec 15, 2007, at 13:12 , Konrad M. wrote:

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…

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 W.

Quoth Ryan D.:

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…

It won’t remove trailing whitespace but that’s more of an EPEBCAK.

Regards,

On Dec 15, 11:51 am, Martin DeMello [email protected] 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.com/komodo

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

  • Eric

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.sapphiresteel.com

Following Eric’s disclaimer (above), I guess I should point out that I
am the Technology Director of Ruby In Steel :wink:

best wishes
Huw

On Dec 15, 11:39 pm, Ryan D. [email protected] wrote:

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

MonkeeSage wrote:

Probably something similar can be written/found for vim.
exe “:%retab”
endfunction

Regards,
Jordan

http://vim.wikia.com/wiki/Auto_remove_white_space_when_saving

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs