Friday, April 29, 2011

format code from ide ( VS2008)

Every once in a while I will paste in some code and it will lose all its tabs and look pretty bad

I know that in the vs2008 xml viewer there is a button to format(indent) all the code to the correct hierarchy

Is there such a function or macro or shortcut key that i could apply this to a section of code (or to all the code in that window)?

From stackoverflow
  • Edit Menu - then Advanced - then Format Selection (if you have it highlighted).

    Shortcut Key is: Ctrl + E, F (for selection) and Ctrl + E, D (for document)

  • Careful on the keyboard shortcuts, I think they are dependent upon the developer environment style settings, e.g. my format document is Ctrl+K, D

  • Item #42 from "Pimp My IDE": 101 Visual Studio tips, tricks, and add-ins by Brian Schroer. Some of the other tips are pretty good too.


Post a Comment