问题
How to auto format code in VS2012 to save time typing and deleting spaces and tabs?
回答1:
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.
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.
回答2:
I use the following combination to auto format indentations of my code in VS2012.
Unformatted code bock in web.config:
Ctrl + A to select all the code in a file to be formatted in VS2012. Or you can select just a block of the code manually.
Ctrl + K, then Ctrl + F will format the code with proper indentations.
Formatted code block
来源:https://stackoverflow.com/questions/16062057/how-to-auto-format-code-indentations-in-vs2012