How to auto format code indentations in VS2012?

mitaka picture mitaka · Apr 17, 2013 · Viewed 46.7k times · Source

How to auto format code in VS2012 to save time typing and deleting spaces and tabs?

enter image description here

Answer

Walt Ritscher picture Walt Ritscher · Apr 17, 2013

If you are looking to format the code as you enter the text, there are some additional settings in Tools\Options\Text Editor area.

Since your example appears to be a config file (XML) look at the XML editor.

enter image description here

Otherwise, to format at any time, the suggestions from @mitaka and @Xaruth are good.

Be aware that the keystrokes to activate Format Document and Format Selection are different depending on what Development Settings you have active in Visual Studio. To see which keystrokes are assigned to the command in your copy of VS look in the Edit menu.

enter image description here