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