Vim reindent/beautify tip

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

On Sunday, 14 May 2006 at 09:56:27 pm +0900, [email protected]
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.

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.

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 :slight_smile:

-Justin