How to smart indent VIM with comment indenting

Vim tends to do nice indenting but wants to leave comments without one by default. This makes code look bad. This is a short reminder on how to make it right.

Configuration file

Set following to your ~/.vimrc :

filetype indent on
set autoindent

And that's it :)

Indent a non-indented file

If you've got a file that needs re-indenting open it with vim and issue following command :

:gg=G

And you've just indented the file.

Comments and suggestions

If you find bugs above please comment below. Also feel free to rate.