views:

515

answers:

3

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)?

+4  A: 

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)

Jeff Olson
+2  A: 

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

SteveC
+1  A: 

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.

Aplato