25 May 2012

I just found out how to indent multiple lines in Vim. Use = at the line where you want to start the auto-indentation. Then move to the line where you want to auto-indent until.

Example: if you are in normal mode, and want to indent the current line and the next 2 lines, you would do =, then 2j.

To auto-indent the full file, and you were at the top of the file, you could do =G.

You can also select the lines in visual mode and then use =, but that might require a few more keystrokes.