Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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) 
like image 940
Michael Goldshteyn Avatar asked Oct 13 '10 14:10

Michael Goldshteyn


People also ask

How do I beautify XML in Visual Studio?

To access XML formatting options, choose Tools > Options > Text Editor > XML, and then choose Formatting.

How do you indent XML code in Visual Studio?

On Windows Shift + Alt + F. On Mac Shift + Option + F. On Linux Ctrl + Shift + I.

How do I tidy up code in Visual Studio?

Right-click on the project or solution name in Solution Explorer, select Analyze and Code Cleanup, and then select Run Code Cleanup.

Can Visual Studio edit XML?

The XML editor in Visual Studio is based on the text editor and includes additional support for the XML languages. When you open an XML file in Visual Studio, it opens in the XML editor. The XML editor includes the following features: XML 1.0 syntax checking.


1 Answers

Yes you can :

Edit > Advanced > Format document (Ctrl+K Ctrl+D) 
like image 147
Julien Hoarau Avatar answered Sep 29 '22 06:09

Julien Hoarau