【问题标题】:How to remove all C# methods/properties/fields "summary" comments (starting with ///) in current document in Visual Studio with one shot?如何一键删除Visual Studio当前文档中的所有C#方法/属性/字段“摘要”注释(以///开头)?
【发布时间】:2012-11-02 08:14:38
【问题描述】:

如何删除所有 C# 方法/属性/字段“摘要”cmets

(以///开头)

在 Visual Studio 中的当前文档中一次拍摄?

换句话说,转换这个:

/// <summary>
/// Very stupid comment generated with very stupid tool
/// </summary>
protected void MyMethod
{

}

进入这个:

protected void MyMethod
{

}

【问题讨论】:

    标签: c# visual-studio


    【解决方案1】:

    正则表达式模式^.*\/\/\/ ?&lt;summary&gt;.*\n(?:^.*\/\/\/.*$\n)* 在这种情况下会更合适,因为它会一次匹配整个摘要评论。

    • ^.*\/\/\/ ?&lt;summary&gt;.*\n - 匹配带有 /// &lt;summary&gt; 文本的行(斜杠后有可选空格)
    • (?:)+ - 非捕获组,重复零次或多次
    • ^ - 行首
    • .* - 任何字符
    • \/\/\/ - 三个斜线
    • .* - 任何字符
    • $ - 行尾
    • \n - 换行符

    【讨论】:

    • 这是删除摘要 cmets 的真正答案!
    【解决方案2】:

    怎么样

    • Ctrl+H快速替换
    • 标记Use : Regular expressions
    • 在表达式 ^.*\/\/\/.*$\n 之后输入 Find what 字段(很快 - 与 /// 模式一致)
    • Replace with 字段留空
    • 确保您在Look inCurrent Document
    • 点击Replace All
    猜你喜欢
    • 2014-11-30
    • 2019-01-16
    • 2019-10-10
    • 1970-01-01
    • 2015-01-18
    • 2011-02-10
    • 2015-12-04
    • 2012-01-06
    • 2020-02-06
    相关资源
    最近更新 更多