Reformat XML in Visual Studio 2010

Is there an easy way to reformat an XML file while viewing it Visual Studio 2010. For example, if you open a generated app.config file, it might look like:

<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

This is difficult to read, is there a way to instruct Visual Studio 2010 to format this, so that it looks more like:

<?xml version="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

Thanks for any help.

Update: With credit to Julien Hoarau for one of the answers. The answers are:

Edit -> Advanced -> Format Document (Ctrl+K, Ctrl+D)
Edit -> Advanced -> Format Selection (Ctrl+K, Ctrl+F)

是的你可以 :

Edit > Advanced > Format document (Ctrl+K Ctrl+D)

If you want to leave your right hand free to do something else, you can use Ctrl+E, Ctrl+D.

Not sure how this is different from Ctrl+K, Ctrl+D.


Not 100% sure about VS2010, but in VS2015 if you copy and paste a long string of XML into an .XML document, it will automatically reformat it.

("Format Document" is usually the way to go, just mentioning another option.)

链接地址: http://www.djcxy.com/p/60144.html

上一篇: XAML编辑器非常慢

下一篇: 在Visual Studio 2010中重新格式化XML