Re-indenting files with vim

Sometimes projects with a long history of committers tend to collect various styles of indentation. Unfortunately not for all programming languages exist specialized tools like indent for C/C++, so we need to find a different way to mass-indent files properly. Using vim is one of them. First you need to create a file (let’s call it /tmp/indent.vim) including all the vim commands you want to run on your code. The following piece is a good start: gg=G :x! »