# Vim reindent/beautify tip

**URL:** <https://www.ruby-forum.com/t/vim-reindent-beautify-tip/60478>\
**Category:** Ruby\
**Created:** [May 14, 2006, 2:57pm UTC](https://www.ruby-forum.com/t/vim-reindent-beautify-tip/60478 "2006-05-14T14:57:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 14, 2006, 2:57pm UTC](https://www.ruby-forum.com/t/vim-reindent-beautify-tip/60478/1 "2006-05-14T14:57:51Z")

</div>

Many of you might already know this but if not here’s an interesting  
tip I just discovered over on [vim.org/tips](http://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

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 14, 2006, 3:16pm UTC](https://www.ruby-forum.com/t/vim-reindent-beautify-tip/60478/2 "2006-05-14T15:16:13Z")

</div>

On Sunday, 14 May 2006 at 09:56:27 pm +0900, removed\_email\_address@domain.invalid  
wrote:

> 1. Hit control-g to discover how many lines are in the file.
> 2. 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.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 14, 2006, 5:40pm UTC](https://www.ruby-forum.com/t/vim-reindent-beautify-tip/60478/3 "2006-05-14T17:40:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 14, 2006, 10:41pm UTC](https://www.ruby-forum.com/t/vim-reindent-beautify-tip/60478/4 "2006-05-14T22:41:45Z")

</div>

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
