步骤:
1、在记事本中编辑好类似下面的脚本代码:
01 Imports System
02 Imports EnvDTE
03 Imports EnvDTE80
04 Imports EnvDTE90
05 Imports EnvDTE90a
06 Imports EnvDTE100
07 Imports System.Diagnostics
08
09 Public Module ModuleTop
10 Sub AddFunComment()
11 Dim DocSel As EnvDTE.TextSelection
12 DocSel = DTE.ActiveDocument.Selection
13 DocSel.NewLine()
14 DocSel.Text = "/*******************************************************************"
15 DocSel.NewLine()
16 DocSel.Text = "* 版权所有: "
17 DocSel.NewLine()
18 DocSel.Text = "* 类 名 称: "
19 DocSel.NewLine()
20 DocSel.Text = "* 功 能: "
21 DocSel.NewLine()
22 DocSel.Text = "* 参 数: "
23 DocSel.NewLine()
24 DocSel.Text = "* 返 回 值: "
25 DocSel.NewLine()
26 DocSel.Text = "* 作 者:XXXXX"
27 DocSel.NewLine()
28 DocSel.Text = "* 电子邮箱:XXXXXX@gmail.com"
29 DocSel.NewLine()
30 DocSel.Text = "* 创建日期: " + System.DateTime.Now.ToString()
31 DocSel.NewLine()
32 DocSel.Text = "*******************************************************************/"
33 End Sub
34
35 End Module
2、VS2010 IDE -> 工具 -> 宏 -> 新建宏项目,选择要保存的位置。然后将要上面的脚本复制进去,保存即可。
3、为你编写的宏绑定快捷键,VS2005 IDE -> 工具 -> 选项 -> 在左边列表中选择“键盘” -> 在右边的“显示命令包含”中,选择你创建宏-> 将光标定位到”按快捷键”处 -> 输入你想命名的快捷键,比如”Alt+C”,保存即可。
注:类内部注释
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Public Module ModuleContent
Sub AddFunComment()
Dim DocSel As EnvDTE.TextSelection
DocSel = DTE.ActiveDocument.Selection
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = " #region<构造方法和析构方法>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endregion<构造方法和析构方法>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#region<常量>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endregion<常量>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#region<变量>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endregion<变量>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#region<属性>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endregion<属性>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#region<方法>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endregion<方法>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#region<事件>"
DocSel.NewLine()
DocSel.NewLine()
DocSel.Text = "#endregion<事件>"
End Sub
End Module
其余步骤同上。