How to Reindent Lines in Vim

Reindenting files helps keep code neat. In Vim, you can reindent an entire file from normal mode (press ESC to get there) by typing gg=G.

You can reindent multiple files with the following commands, in this case reindenting all JavaScript files in the current directory:

:ar *.js
:argdo norm gg=G

You can find more information about those commands with :h like this:

:h ar

See the Vim wiki for more ideas.