randombits
randombits

Reputation: 48450

vim trick to align blocks/end keywords in Ruby?

Is there a way to simply have my blocks and their closing end keyword align properly with vim? If I have a function which is nested with several conditions, things can start to get ugly fast. Can vim save the day?

Upvotes: 3

Views: 615

Answers (3)

todb
todb

Reputation: 329

gg=G

(go to top, re-indent all the way down to the bottom)

Upvotes: 3

Michael Kohl
Michael Kohl

Reputation: 66837

There's also a nice Vim plugin called endwise that automatically inserts the ends for you.

Upvotes: 3

Peter
Peter

Reputation: 132207

Sure. Just select the relevant block of code and press =.

Upvotes: 12

Related Questions