Source_Insight4 配置单行-多行注释快捷键
1. 新建一个文件,命名为linecomment.em,文本内容为:
/* 配置单行/多行注释 */ macro MultiLineComment() { hwnd = GetCurrentWnd() selection = GetWndSel(hwnd) LnFirst =GetWndSelLnFirst(hwnd) LnLast =GetWndSelLnLast(hwnd) hbuf = GetCurrentBuf() if(GetBufLine(hbuf, 0) =="//magic-number:tph85666031"){ stop } Ln = Lnfirst buf = GetBufLine(hbuf, Ln) len = strlen(buf) while(Ln <= Lnlast) { buf = GetBufLine(hbuf, Ln) if(buf ==""){ Ln = Ln + 1 continue } if(StrMid(buf, 0, 1) == "/"){ if(StrMid(buf, 1, 2) == "/"){ PutBufLine(hbuf, Ln, StrMid(buf, 2, Strlen(buf))) } } if(StrMid(buf,0,1) !="/"){ PutBufLine(hbuf, Ln, Cat("//", buf)) } Ln = Ln + 1 } SetWndSel(hwnd, selection) } |
将文件拷贝到SI的Base目录,该目录一般位于: 文档\xxxxx\Projects\Base,如下:
2. 将文件linecomment.em添加到工程源码中
Project->Add and Remove Project File
3. 配置快捷键
Options->KeyAssignment,在命令输入框中输入mu,出现Macro:MultiLineComment, 单击Assign New Key按钮,配置快捷键,一般是选择Ctrl+/,如果已经被占用,会提示是否先删除映射。
然后单击OK
按下Ctrl+/即可实现注释和反注释。如下
注:这种个性化的配置只针对当前工程有效。