【问题标题】:Comment out found lines in VisualStudio在 Visual Studio 中注释掉找到的行
【发布时间】:2017-04-12 06:37:13
【问题描述】:

我正在查看包含以下术语的行的 c# 代码:

System.Drawing.SystemColors.Highlight

我想使用 VisualStudio 的 Find&Replace 功能在包含该术语的每一行前面设置一个注释标记 (//)。

你们知道快速的方法吗?

【问题讨论】:

  • 查找所有“System.Drawing.SystemColors.Highlight”,替换为“//System.Drawing.SystemColors.Highlight”?
  • 将 System.Drawing.Sys... 替换为 // System.Drawing.Sys...
  • 好吧,但是术语前后会有更多的文字......
  • 查找所有内容,然后转到每一行并对其进行评论。由于您不完全知道包含“System.Drawing.SystemColors.Highlight”的每一行会是什么样子,因此提出任何类型的正则表达式可能需要比手工劳动更长的时间。
  • 您可以随时搜索System.Drawing.SystemColors.Highlight并替换为/*System.Drawing.SystemColors.Highlight*/

标签: c# visual-studio comments


【解决方案1】:

你可以用这个:

  • Text to find -> ^(.*System.Drawing.SystemColors.Highlight.*)$
  • Replace with -> //$1
  • 使用 RegEx 搜索选项 -> .* [x] Use Regular Expressions

【讨论】:

    【解决方案2】:

    CTRL + H 打开查找和替换。

    查找“System.Drawing.SystemColors.Highlight
    并将其替换为“// System.Drawing.SystemColors.Highlight”。

    【讨论】:

      【解决方案3】:

      您可以使用正则表达式来做到这一点。

      搜索:(^.*System.Drawing.SystemColors.Highlight.*)$ 替换为://$1

      【讨论】:

      • 已更新。我正在使用 Notepad++ 进行测试。哎呀!
      猜你喜欢
      • 2013-03-25
      • 2019-05-14
      • 2021-06-16
      • 2018-06-01
      • 1970-01-01
      • 2016-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多