VIM tip of the day: quickly reformat your document
Posted: July 25th, 2009 | Author: Kevin | Filed under: Development, Tips, Tool | Tags: indentation, productivity, vim | No Comments »Quickly reformat your document in VIM with:
gg=G
gggoes to the beginning of the document=kicks off the indent filter (:help = for more information)- G goes to the end of the document
Another way to achieve the same result through visual mode is.
ggvG=
gggoes to the beginning of the filevenables visual modeGgoes to end of the file=apply indentation
Similarly, if you are on a line that needs formatting, simply use ==, or v=. You can also select a block of code in visual mode and press = to reformat the selection.
Breath this command and make your team happy.
If you find this post useful, please drop a line in the comments.