Reformat XML in Visual Studio 2010

Michael Goldshteyn picture Michael Goldshteyn · Oct 13, 2010 · Viewed 61.9k times · Source

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)

Answer

Julien Hoarau picture Julien Hoarau · Oct 13, 2010

Yes you can :

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