Visual Studio 2010 文档格式规则
我知道在“工具”>选项(文本编辑器 > CSS > 格式)菜单 我可以在 CSS 文件的三种文档格式(紧凑、半展开和展开)以及大小写之间进行选择。
我的组织已决定在 XML 文件中实现格式化结构,其中元素的属性在连续行上排列,如下所示:
<ElementName attribute1="someValue"
attribute2="someOtherValue"
attribute3="yaddayaddayadda" />
- 是否有一种方法可以为 XML 文件定义自定义格式化规则,以便在格式化文档时用Ctrl+K、Ctrl+DI 得到想要的结果吗?
- 有没有办法定义一个“规则”,在我输入第一个属性后,在第二行插入正确数量的空格?
- 有没有办法让代码片段在粘贴片段时遵循这些规则?
预先感谢您的任何建议。
斯科特.
I know that in the Tools > Options (Text Editor > CSS > Format) menu I can choose between three types of document formatting for CSS files (compact, semi-expanded and expanded) as well as capitalization.
A decision has been made in my organization to implement a formatting structure in XML files, where the attributes for an element line up on successive lines like this:
<ElementName attribute1="someValue"
attribute2="someOtherValue"
attribute3="yaddayaddayadda" />
- Is there a way to define custom formatting rules for XML files so that when I format the document with Ctrl+K, Ctrl+D I get the desired result?
- Is there a way to define a "rule" that will insert the correct number of spaces on the second line after I finish typing the first attribute?
- Is there a way to have code snippets follow these rules when pasting in the snippet?
Thanks in advance for any suggestions.
Scott.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设置此选项:
工具>选项>文本编辑器> XML>格式化>属性>将每个属性对齐在单独的行上。
转到 XML 文档并使用:
编辑>高级>格式化文档。
(CTRL + E, D)
Set this option:
Tools > Options > Text Editor > XML > Formatting > Attributes > Align attributes each on a separate line.
Go to XML document and use:
Edit > Advanced > Format document.
(CTRL + E, D)
否,无法在 Visual Studio 中将 XML 文档格式自定义到此级别。它只允许更粗粒度的格式化。
我认为您唯一的选择是使用另一个工具来确保文档的格式,并让该工具在生成/保存相关文档时运行。本质上是用于 XML 文档的 StyleCop。
No there is no way to customize XML document formatting to this level in Visual Studio. It only allows for much coarser grained formatting.
I think your only option is to use another tool to ensure formatting of documents and have that tool run on build / save of the documents in question. Essentially StyleCop for your XML documents.