tags:

views:

126

answers:

3

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?

+7  A: 

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

Peter
+1: I've been using Vim for about 6 years, and I never knew this.
Mark Rushakoff
Actually, this is *just* what I needed. Awesome, thanks Peter.
randombits
All this seems to do for me is move everything selected to the same column. What am I missing?
@.yahoo-co-jpaqwsykcj3aulh3h1: you should `:set ft=ruby` first. This means you won't have ruby indenting support turned on.
Peter
Thanks Peter. The filetype was correct but it looks like I was missing "filetype plugin indent on" in the config file.
+2  A: 

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

Michael Kohl
+2  A: 
gg=G

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

todb