VC下用宏来实现函数注释的自动添加
来源:互联网 发布:淘宝教程 华为网盘 编辑:程序博客网 时间:2024/05/20 03:44
今天看代码,看到一些代码没有函数注释,突然想到可以用宏来实现注释的自动添加,还添加了按钮,颇有成就感,故总结一下,积累经验。 Vc下面可以直接录制宏(Tools->Record quick Macros),这样可以把鼠标,键盘动作录制下来,录制以后可以编辑,(Tools->Macro,选中宏名称,点 EDIT 就可以进入宏文件中进行编辑)。默认的存储文件名是 MYMACRO.DSM,也可以直接打开编辑. 编辑代码是用vbs 写的,代码如下:
'------------------------------------------------------------------------------
'FILE DESCRIPTION: New Macro File
'------------------------------------------------------------------------------
Sub FunctionHead()
'DESCRIPTION: 函数注释 标准格式
'Begin Recording
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//"
ActiveDocument.Selection = "/*"
for i=0 to 100
ActiveDocument.Selection = "="
next
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//函数名:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//作者:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//日期:"
ActiveDocument.Selection = Date
ActiveDocument.Selection = " "
ActiveDocument.Selection = Time
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//功能:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//输入参数:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//返回值:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//修改记录:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//备注:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//"
for i=0 to 100
ActiveDocument.Selection = "="
next
ActiveDocument.Selection = "*/"
ActiveDocument.Selection.NewLine
'End Recording
End Sub
Sub FileHead()
'DESCRIPTION: 文件注释 标准格式
'Begin Recording
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//"
ActiveDocument.Selection = "/*"
for i=0 to 100
ActiveDocument.Selection = "="
next
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//文件名:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//作者:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//日期:"
ActiveDocument.Selection = Date
ActiveDocument.Selection = " "
ActiveDocument.Selection = Time
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//功能:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//修改记录:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//备注:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//"
for i=0 to 100
ActiveDocument.Selection = "="
next
ActiveDocument.Selection = "*/"
ActiveDocument.Selection.NewLine
'End Recording
End Sub
'------------------------------------------------------------------------------
'FILE DESCRIPTION: New Macro File
'------------------------------------------------------------------------------
Sub FunctionHead()
'DESCRIPTION: 函数注释 标准格式
'Begin Recording
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//"
ActiveDocument.Selection = "/*"
for i=0 to 100
ActiveDocument.Selection = "="
next
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//函数名:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//作者:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//日期:"
ActiveDocument.Selection = Date
ActiveDocument.Selection = " "
ActiveDocument.Selection = Time
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//功能:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//输入参数:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//返回值:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//修改记录:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//备注:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//"
for i=0 to 100
ActiveDocument.Selection = "="
next
ActiveDocument.Selection = "*/"
ActiveDocument.Selection.NewLine
'End Recording
End Sub
Sub FileHead()
'DESCRIPTION: 文件注释 标准格式
'Begin Recording
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//"
ActiveDocument.Selection = "/*"
for i=0 to 100
ActiveDocument.Selection = "="
next
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//文件名:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//作者:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//日期:"
ActiveDocument.Selection = Date
ActiveDocument.Selection = " "
ActiveDocument.Selection = Time
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//功能:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//修改记录:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//备注:"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//"
for i=0 to 100
ActiveDocument.Selection = "="
next
ActiveDocument.Selection = "*/"
ActiveDocument.Selection.NewLine
'End Recording
End Sub
在写完宏后,可以选择 Tools->Macro->Option ->Toolbats,把新制作的宏做成按钮显示,然后选择一个配套的icon,就可以在需要时直接加入注释了,很方便的哦,如果不够你还可以添加快捷键完全使用键盘操作。。。。。。。。。。。。
原文地址:http://blog.csdn.net/sangxiansheng/article/details/2487170
0 0
- VC下用宏来实现函数注释的自动添加
- VC下使用Macro (vbs)来实现标准函数注释的自动添加
- VC下使用Macro (vbs)来实现标准函数注释的自动添加
- VS2012自动添加函数注释
- 3个很有用VC的IDE工具宏:添加函数注释块、注释、取消注释
- 3个很有用VC的IDE工具宏:添加函数注释块、注释、取消注释
- 在CPP文件中自动添加函数注释的ADDIN
- 在CPP文件中自动添加函数注释的ADDIN
- vs2005 为函数自动添加注释
- Visual Studio 自动添加函数注释宏
- VS 2005 为函数自动添加注释
- vs2005 为函数自动添加注释
- vs2005 为函数自动添加注释
- vs 为函数自动添加注释
- 给VC添加注释块的功能
- vim自动生成main函数和自动添加注释
- 自动添加注释(转)
- VS 自动添加注释
- 2013年07月19日
- Hibernate配置文件元素详解
- Hibernate 脏数据检查
- perl 文件读写合并数据分割 去重 windows
- 工厂方法模式与抽象工厂模式
- VC下用宏来实现函数注释的自动添加
- EXCEL 2010怎样固定表头
- 内核模块编译
- 启动和停止init.rc中的服务
- 慎用CreateParms重载窗体属性
- iOS开发牛人博客收集
- 程序员未来高薪就业 学习linux才是王道
- sphinx在erver2008无法启动,Error 1067: The process terminated unexpectedly
- Java 通配符 ? T E