Visual Studio Keyboard Tip #3 - Formatting

To automatically format your code in Visual Studio 2005 use the following keyboard shortcuts:

Format Document: CTRL + E, then D
Format Selection: CTRL + E, then F

If you have any syntax errors in your code then the formatting features do not seem to work. So, if you are trying to use the keyboard shortcuts to format a document and it doesn’t seem to be working, then check your code.

The formatting engine is great. You are also able to customize what the format style you want to use for each language you work with. Go to the Tools menu, click Options. Select Text Editor, then the language, for example C#. Expand the node in the tree (C# in this case) and you’ll see either a Format or Formatting child node. Once you select that you’ll see the options available to you.