Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto format code indentations in VS2012? [closed]

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

enter image description here

like image 967
mitaka Avatar asked Apr 17 '13 13:04

mitaka


People also ask

How do I automatically indent a code?

To automatically indent the highlighted text, select Auto-indent Selection or press Ctrl+I. To automatically format the highlighted text, select Auto-format Selection or press Ctrl+;. To adjust the wrapping of the selected paragraph, select Rewrap Paragraph or press Ctrl+E followed by R.

How do I automatically indent code in Visual Studio?

Select the text you want to automatically indent.Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.

How do you auto correct indentation in Python Vscode?

Highlight/ select the lines you want indented, then press TAB as often as needed until they reach the proper indent level. You can remove spaces with SHIFT TAB . You can also use CTRL+ALT+I to auto-indent the selection.


1 Answers

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

like image 82
Walt Ritscher Avatar answered Sep 21 '22 11:09

Walt Ritscher