【问题标题】:Is there a simple way to create a custom VS action for personalised comments?有没有一种简单的方法可以为个性化评论创建自定义 VS 操作?
【发布时间】:2012-03-08 11:32:16
【问题描述】:

请随意大量改写这个问题。

基本上,我目前正在剥离一个非常大的框架的很大一部分 - 这涉及大量评论。所以我可以稍后找到所有这些我正在批量评论,然后在每个块之前复制粘贴一个标记,如下所示:

//MYINITIALS_REMOVE
/*if (this code is rubbish)
{
    comment it out;
}*/

我想创建一个函数,以便通过按一个按钮或组合键我批量注释掉选定的代码并自动将我的标签放在开头。因此,开头的注释不是“//”或“/*”,而是“MYINITIALS_REMOVE//”或“MYINITIALS_REMOVE/*”

这可能吗?

编辑实际上考虑一下,如果每一行都以“MYINITIALS_REMOVE//”开头,我什至不介意。

【问题讨论】:

    标签: visual-studio visual-studio-2010 macros shortcuts visual-studio-macros


    【解决方案1】:

    我想你正在寻找这个:

    Public Sub CStyleComment()
        Dim selection As TextSelection = DTE.ActiveDocument.Selection
        selection.TopPoint.CreateEditPoint.Insert("//MYINITIALS_REMOV" & vbCrLf & "/*")
        selection.BottomPoint.CreateEditPoint.Insert("*/")
    End Sub
    

    也许这个版本更合适(自动翻译):

    Public Sub CStyleComment()
        Dim selection As TextSelection = DTE.ActiveDocument.Selection
        selection.TopPoint.CreateEditPoint.Insert("//MYINITIALS_REMOV" & vbCrLf & "/*")
        selection.BottomPoint.CreateEditPoint.Insert("*/")
    End Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-27
      • 1970-01-01
      • 2011-02-16
      • 1970-01-01
      • 2010-09-06
      • 2014-01-10
      • 2012-02-25
      相关资源
      最近更新 更多