Vi Magics

I was working with coder of drupal from past 3 days and had removed 7000 errors from a particular module. But i have done it with VI-Editor by following Commands.

1.For Removing all leading spaces

:1,$s/^\s*//gc

I have used gc so that it will confirm for every instance on every line.
2. Make an indentation of 2 spaces for every line starting.

:%s!^!  !

3. Replacing

,

with

, 
 :%s/,/, /gc

4. For deleting all trialing spaces at the end of line

:%s/ \+$//c

These are the main problem in every module of drupal which is contributed so removing all this i have used up detailed steps