Monday, November 30, 2009

How do I fix the indentation of an entire file in Vim?

How do I fix the indentation of an entire file in Vim?

In Vim, what is the command to correct the indentation of all the lines?

Often times I'll copy and paste code into a remote terminal and have the whole thing messed up. I want to fix this in one fell swoop.

Solution:

gg=G

=, the indent command can take motions. So, gg to get the start of the file, = to indent, G to the end of the file.

No comments: