Frage

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

enter image description here

War es hilfreich?

Lösung

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

Andere Tipps

I use the following combination to auto format indentations of my code in VS2012.

Unformatted code bock in web.config: Unformatted xml block

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 enter image description here

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top