Source Insight-常用设置与使用(三)
作者:互联网
一、开发环境及工具
- Windos 10
- Source Insight v3.5/v4.0 (https://www.sourceinsight.com/)
二、高亮显示快捷键设置
点击Assign New Key后在弹框中输入自定义的快捷键即可,这里设置为Ctrl+`
三、添加注释快捷键
这里演示添加单行注释“//”和宏注释“#ifdef 0, #endif”的方法
1、打开软件自带的Base项目
2、在utils.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)
}
// 添加宏注释
macro AddMacroComment()
{
hwnd=GetCurrentWnd()
sel=GetWndSel(hwnd)
lnFirst=GetWndSelLnFirst(hwnd)
lnLast=GetWndSelLnLast(hwnd)
hbuf=GetCurrentBuf()
if(LnFirst == 0) {
szIfStart = ""
}else{
szIfStart = GetBufLine(hbuf, LnFirst-1)
}
szIfEnd = GetBufLine(hbuf, lnLast+1)
if(szIfStart == "#if 0" && szIfEnd == "#endif") {
DelBufLine(hbuf, lnLast+1)
DelBufLine(hbuf, lnFirst-1)
sel.lnFirst = sel.lnFirst – 1
sel.lnLast = sel.lnLast – 1
}else{
InsBufLine(hbuf, lnFirst, "#if 0")
InsBufLine(hbuf, lnLast+2, "#endif")
sel.lnFirst = sel.lnFirst + 1
sel.lnLast = sel.lnLast + 1
}
SetWndSel( hwnd, sel )
}
3、按照上面添加高亮快捷键的方式搜索MultiLineComment和AddMacroComment并添加对应快捷键,这里分别设为Ctrl+1和Ctrl+3
4、注释快捷键效果演示
标签:常用,Ln,hwnd,Insight,lnLast,Source,hbuf,sel,buf 来源: https://blog.csdn.net/AmxTech/article/details/113774316