visual-studio 在 Visual Studio 2010 中重新格式化 XML
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3924783/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Reformat XML in Visual Studio 2010
提问by Michael Goldshteyn
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:
在 Visual Studio 2010 中查看 XML 文件时是否有一种简单的方法可以重新格式化它。例如,如果打开生成的 app.config 文件,它可能如下所示:
<?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:
这很难阅读,有没有办法指示 Visual Studio 2010 对其进行格式化,使其看起来更像:
<?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:
更新:感谢 Julien Hoarau 提供的答案之一。答案是:
Edit -> Advanced -> Format Document (Ctrl+K, Ctrl+D)
Edit -> Advanced -> Format Selection (Ctrl+K, Ctrl+F)
回答by Julien Hoarau
Yes you can :
是的你可以 :
Edit > Advanced > Format document (Ctrl+K Ctrl+D)
回答by Paul Spangle
If you want to leave your right hand free to do something else, you can use Ctrl+E, Ctrl+D.
如果你想让你的右手自由地做其他事情,你可以使用Ctrl+ E, Ctrl+ D。
Not sure how this is different from Ctrl+K, Ctrl+D.
不确定这与Ctrl+ K,Ctrl+有何不同D。
回答by Jemmeh
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.
不是 100% 确定 VS2010,但在 VS2015 中,如果您将一长串 XML 复制并粘贴到 .XML 文档中,它会自动重新格式化。
("Format Document" is usually the way to go, just mentioning another option.)
(“格式化文档”通常是要走的路,只是提到了另一种选择。)

