VS2005 使用 宏 添加快捷键 自动生成代码

第一步:Alt + F8 呼出宏资源管理器


第二步:右键 Samples -> 新建模块   作者起名字为Normal,文件内容如下:

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module Normal

    'Ctrl +  小键盘 2
    Sub NetHelper_MethodHeader_Ctrl_2()
        DTE.ActiveDocument.Selection.Text = "///"
        DTE.ActiveDocument.Selection.LineDown()
        DTE.ActiveDocument.Selection.EndOfLine()
        DTE.ActiveDocument.Selection.NewLine()
        DTE.ActiveDocument.Selection.Text = "<remark>"
        DTE.ActiveDocument.Selection.NewLine()
        DTE.ActiveDocument.Selection.LineUp()
        DTE.ActiveDocument.Selection.EndOfLine()
        DTE.ActiveDocument.Selection.NewLine()
        DTE.ActiveDocument.Selection.Text = "<para/>Author   :  AnDequan"
        DTE.ActiveDocument.Selection.NewLine()
        Dim d = Now
        DTE.ActiveDocument.Selection.Text = "<para/>Date     :  " + Format(d, "yyyy-MM-dd HH:mm:ss")
    End Sub

    'Ctrl +  小键盘 1
    Sub NetHelper_SingleLine_Ctrl_1()
        Dim d = Now
        DTE.ActiveDocument.Selection.Text = "// An " + Format(d, "yyyy-MM-dd HH:mm:ss") + " []"
        DTE.ActiveDocument.Selection.CharLeft()
        DTE.ActiveDocument.Selection.Text = " "
        DTE.ActiveDocument.Selection.CharLeft()
        DTE.ActiveDocument.Selection.Text = " "
    End Sub


End Module

第三步:设置快捷键 



第四步:使用快捷键,校验结果如下:

猜你喜欢

转载自blog.csdn.net/CsethCRM/article/details/111642230
今日推荐