01110000 01100001 01110011 01110011 01101001 01101111 01101110

VIM tip of the day: quickly reformat your document

Posted: July 25th, 2009 | Author: Kevin | Filed under: Development, Tips, Tool | Tags: , , | No Comments »

Quickly reformat your document in VIM with:

gg=G
  • gg goes 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=
  • gg goes to the beginning of the file
  • v enables visual mode
  • G goes 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.

Like this post? Why not it with the world?
  • Digg
  • del.icio.us
  • Facebook
  • Reddit
  • Google Bookmarks
  • DZone
  • LinkedIn


Leave a Reply