Last Updated: February 25, 2016
·
719
· peterssonjesper

Reindent an entire file

ggVG=

gg  Goes to the first line
V   Enters visual mode
G   Goes to last line
=   Reindents current selection

5 Responses
Add your response

This is even shorter (you don't need to go to visual mode)

gg=G</code></pre>
over 1 year ago ·

Is this different from :retab ?

over 1 year ago ·

@s1na
Yes, this is different.
:retab converts tabs to spaces, or spaces to tabs
gg=G fixes indentation level

over 1 year ago ·

@vimrocks Thanks, I didn't know that. Awesome!

over 1 year ago ·

@vimrocks
Ah, great. Thanks ;)

over 1 year ago ·