Source Insight快捷键 利用“//”逐行注释

在写代码时,经常会使用“//”注释代码,但在Source Insight中是没有快捷键利用“//”逐行注释代码的,可以用如下方法解决。

步骤一:打开Projcet->Open project,输入base,选择Base,可以看到utils.em文件,打开utils.em文件,将下面代码加入Utils.em文件中,保存。

Source Insight快捷键 利用“//”逐行注释Source Insight快捷键 利用“//”逐行注释

(网络上找到如下代码)

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)

}

Source Insight快捷键 利用“//”逐行注释

步骤二:打开Options->KeyAssignments,输入如下字符Mul,选择Assign New Key...,例如:按入“Ctrl+/”快捷键,点击"OK"即可。

Source Insight快捷键 利用“//”逐行注释Source Insight快捷键 利用“//”逐行注释

Source Insight快捷键 利用“//”逐行注释

Source Insight快捷键 利用“//”逐行注释