前言
Source insight是一款非常优秀的代码阅读软件,但是有些地方还是不够完善,比如没有快速对一段代码进行注释的功能。对于此类需求,我们可以借助宏来实现。网上有很多source insight的宏,这里只介绍我觉得比较好用的几个。
MultiLineComment.em:实现多行注释的宏代码
AddMacroComment.em:实现添加“#if 0”和“#endif”的宏代码
quicker.em: 该宏功能扩展文件是华为某员工进行整理和开发的,功能十分强大
一、安装source insight宏
1、将宏文件放入工程代码所在的文件夹
2、将宏文件添加到工程中
二、设置宏快捷键
1、Options->Key Assignments,找到Macro: MultiLineComment,添加快捷键即可,推荐使用**Ctrl+/**组合键。
2、Options->Key Assignments,找到Macro: AddMacroComment,添加快捷键即可,推荐使用Ctrl+3组合键(数字3对应#号,方便记忆)。
3、Options->Key Assignments,找到Marco:AutoExpand,添加快捷键即可,推荐使用Ctrl+Enter组合键。(这里用到了quicker.em)
三、测试快捷键
1、Ctrl + / 多行注释
2、Ctrl + 3 添加“#if 0”和“#endif”
四、quicker.em使用介绍
使用方法
在文件空白处输入 quicker.em 支持的命令,按下 Ctrl+Enter 即可
支持命令
/*==============================================*
*====== List Quicker supports commands ========*
*----------------------------------------------*
*
* /* auto fill comment according to standard C format
* // auto fill comment according to standard C format
* { auto add right curly bace
*
* name auto record author's name
* if auto insert if condition statements template
* ef auto insert else if condition statements template
* ife auto insert if/else condition statements template
* ifs auto insert if/else if/else condition statements template
* else/ei auto insert else statements template
*
* switch/sw auto insert switch/case statements template
* case/ca auto insert case/break statements template
*
* for auto insert for loop statements template
* fo auto insert for loop statements template
* while/wh auto insert while loop statements template
* do auto insert do/while loop statements template
*
* func/fu auto insert function header description template
* file/fi auto insert file header description template
* hi auto insert new history record in history comment
* struct/st auto insert typedef struct statements template
* enum/en auto insert typedef enum statements template
*
* ap auto insert problem number and description comment
*
* pn set problem number used by below command
*
* ab auto insert add begin description for assigned PN comment
* ae auto insert add end description for assigned PN comment
* db auto insert delete begin description for assigned PN comment
* de auto insert delete end description for assigned PN comment
* mb auto insert modify begin description for assigned PN comment
* me auto insert modify end description for assigned PN comment
* abg auto insert add begin and end description for assigned PN comment
* mbg auto insert modify begin and end description for assigned PN comment
* dbg auto insert delete begin and end description for assigned PN comment
*
* hd auto create .h header file for current .c file
* hdn auto create new .h header file for current .c file
*
* key list Source Insight default shortcut keys
* cmd/help list Quicker supports commands just this showed
*
* #if auto insert #if statements template
* #ifd/#ifdef auto insert #ifdef statements template
* #ifn/#ifndef auto insert #inndef statements template
*
* cpp auto insert extern C statements template
* tab auto expand tab to assigned spaces
*
*----------------------------------------------*
*======= End Quicker supports commands ========*
*==============================================*/
使用演示
1、输入help ,按Ctrl+Enter查看所支持的命令
2、输入fi ,按Ctrl+Enter创建文件说明
以上宏文件及更多宏文件获取渠道:https://wwu.lanzoul.com/iYCqE0amkdde