source insight4.0 implements multi-line code comment function

source insight4.0 implements multi-line code comment function

Arbitrary project implementation in global state

When using source insight to edit code, it is very troublesome for multi-line comments. Today, Baidu searched for source insight multi-line comment methods, as follows.

Multi-line comments can be realized by adding macros and shortcut keys in source insight. Generally, the shortcut keys are ctrl+/ to achieve settings.

First open the base project in the source insight project,
insert image description here
open utils.em and
insert image description here
add the following code at the end of the code (Baidu search, tested and available)

 
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)  //取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)
}

After saving, do the following operations.
insert image description here
Set the shortcut key.
insert image description here
The following interface appears.
insert image description here
After clicking, you can set the shortcut key. Press ctrl+/
insert image description here
as follows to set up successfully.
insert image description here
At this point, the multi-line comment shortcut key ctrl+/ can be used. Select the code to be commented and press ctrl+/ That's it, convenient and fast.

Reprinted in: https://blog.csdn.net/qq_38240926/article/details/102457793

Guess you like

Origin blog.csdn.net/DADWAWFMA/article/details/122347743