VIM^s#03 Indent the whole file

This is a very interesting requirement that I came across and as usual I started looking for solutions.
How do I auto-indent the whole file in one shot?
In VIM, it turned out to be very simple than I thought. Its,

gg=G

where,
gg – would take you to the first line of the file
= – would invoke the auto-indentation
G – would tell to do it till the last line of the file.

Isn’t that wonderful?
For further/eloborate details on the same, checkout the following link:
http://stackoverflow.com/questions/506075/how-do-i-fix-the-indentation-of-an-entire-file-in-vi

Advertisements

About this entry