Visual Studio 2010 文档格式规则

发布于 2024-09-15 23:56:07 字数 496 浏览 2 评论 0原文

我知道在“工具”>选项(文本编辑器 > CSS > 格式)菜单 我可以在 CSS 文件的三种文档格式(紧凑、半展开和展开)以及大小写之间进行选择。

我的组织已决定在 XML 文件中实现格式化结构,其中元素的属性在连续行上排列,如下所示:

<ElementName attribute1="someValue"
             attribute2="someOtherValue" 
             attribute3="yaddayaddayadda" />
  1. 是否有一种方法可以为 XML 文件定义自定义格式化规则,以便在格式化文档时用Ctrl+K、Ctrl+DI 得到想要的结果吗?
  2. 有没有办法定义一个“规则”,在我输入第一个属性后,在第二行插入正确数量的空格?
  3. 有没有办法让代码片段在粘贴片段时遵循这些规则?

预先感谢您的任何建议。

斯科特.

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" />
  1. 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?
  2. 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?
  3. Is there a way to have code snippets follow these rules when pasting in the snippet?

Thanks in advance for any suggestions.

Scott.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

靖瑶 2024-09-22 23:56:08

设置此选项:

工具>选项>文本编辑器> 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)

装纯掩盖桑 2024-09-22 23:56:08

否,无法在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文