Forum: Ruby vim reindent/beautify tip

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2006-05-14 16:57
(Received via mailing list)
Many of you might already know this but if not here's an interesting
tip I just discovered over on vim.org/tips.

Base assumption: you have installed the ruby-vim gem and the vim
files are in the correct places.

If you have old ruby files that have screwed up formatting, you can
beautify them (re-indent) using vim.

1. Open the file.
2. Hit control-g to discover how many lines are in the file.
3. While still in command-mode, type that number and then type
"==" (without the quotes). It will reindent everything.

cr
Henry T. So Jr. (Guest)
on 2006-05-14 17:16
(Received via mailing list)
On Sunday, 14 May 2006 at 09:56:27 pm +0900, 
removed_email_address@domain.invalid
wrote:
> 2. Hit control-g to discover how many lines are in the file.
> 3. While still in command-mode, type that number and then type
> "==" (without the quotes). It will reindent everything.
>
> cr

A slightly easier way to do this is to type =G (capital G) when the
cursor is on the top line of the file.

Henry.
Mike N. (Guest)
on 2006-05-14 19:40
Henry T. So Jr. wrote:
> A slightly easier way to do this is to type =G (capital G) when the
> cursor is on the top line of the file.

or from anywhere,

gg=G

i think the gem name actually vim-ruby... or maybe not because, whenever
I do =G the indenting gets really messed up.
Justin C. (Guest)
on 2006-05-15 00:41
(Received via mailing list)
Mike N. wrote:
> i think the gem name actually vim-ruby... or maybe not because, whenever
> I do =G the indenting gets really messed up.
>
>
Or, use 'v' to enter visual mode, highlight the section you want to
re-indent, and press '='

A variety of options :)

-Justin
This topic is locked and can not be replied to.