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

混江龙づ霸主 提交于 2019-12-03 13:33:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!