开发者

Visual Studio 2010 Document Formatting Rules

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" t开发者_运维技巧hat 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.


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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜