在Visual Studio 2010中防止评论格式化

5
我正在对一个API进行内联文档编写,使用XML注释,并且希望保留缩进。每次格式化文档(CTRL+K CTRL+D)时,所有/* */内的缩进都会被删除。有没有选项可以防止这种情况发生?看起来如果我使用单行注释,就可以保留缩进,但我不想采用这种方法。谢谢您的时间。
/*
<ObjectProperty Name="id" Type="string" DefaultValue="''">
<Description>
Unique identifier of the data store. Primarily used for getting a handle  <docref class="ObjectManager">ObjectManager</docref>.
</Description>
<Examples>
<Example>
// Create an anonymous DataStore
// Update and Sort the data by using ObjectManager
new DataStore({ id: 'PersonsDS' });
ObjectManager.GetDataStore('PersonsDS').UpdateData([
{
ID: 1,
FirstName: 'Joe',
LastName: 'Bloggs'
},
{
ID: 2,
FirstName: 'Jane',
LastName: 'Doe'
}
]).Sort('LastName', 'desc');
</Example>
</Examples>
</ObjectProperty>
*/

应该看起来像

/*
<ObjectProperty Name="id" Type="string" DefaultValue="''">
    <Description>
        Unique identifier of the data store. Primarily used for getting a handle  <docref class="ObjectManager">ObjectManager</docref>.
    </Description>
    <Examples>
        <Example>
            // Create an anonymous DataStore
            // Update and Sort the data by using ObjectManager
            new DataStore({ id: 'PersonsDS' });
            ObjectManager.GetDataStore('PersonsDS').UpdateData([
            {
                ID: 1,
                FirstName: 'Joe',
                LastName: 'Bloggs'
            },
            {
                ID: 2,
                FirstName: 'Jane',
                LastName: 'Doe'
            }
            ]).Sort('LastName', 'desc');
        </Example>
    </Examples>
</ObjectProperty>
*/

1
我无法重现这种行为。 - Dave
@Dave 你将第二个代码块粘贴到VS2010中,格式化文档,而且没有失去缩进吗?这让我有希望它是可能的。 - Brett
1
是的,我拿了你的第二个(格式化的)代码块,粘贴到我的编辑器中,按下CTRL-K,CTRL-D,它重新格式化了页面上的所有代码,但保留了你的注释。 - Dave
@Dave。当你说“我的编辑器”时,你是在使用VS2010吗?有没有什么选项更改会影响到这个问题?感谢你的帮助。 - Brett
1
是的,我正在使用 VS2010。我正在使用编辑器的默认设置,但是我也加载了 Productivity Power Tools 扩展。 - Dave
1个回答

1
在安装了 Microsoft 的免费扩展程序 Productivity Power Tools(一个必备工具)的 Visual Studio 2010 中,当使用 Ctrl + K, D 自动格式化文件时,注释中的格式将被保留,因此不会出现该问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接