source insight配置(自动排版,多标签显示,注释,删除中文乱码)

一.下载ASTYLE_2.0(自动排版)
1,http://pan.baidu.com/s/1nu5Apdv
2,打开你的SourceInsight, 选择菜单“Options–>Custom Commands–>Add”, 输入Artistic Style(可以随便输入一个名字)。
3,Run中输入: “”D:\Source insight\ASTYLE_2.0\AStyle\bin\AStyle.exe” –style=ansi -s4 -S -N -L -m0 -M40 –convert-tabs –suffix=.pre %f(前面是ASTYLE的路径(注意路径不可以是中文的))
4,Dir留空,将Iconic Window, File,then Line 前打上勾。
5,然后点对话框中右侧的按钮“Menu”, Menu—>Menu–>View–>, 右侧Insert, OK.
6,此时在SourceInsight中的View菜单下多了个Style的子菜单选项,可以用它来对单个C/C++文件进行格式化。
二.下载TabSiPlus多标签显示
http://pan.baidu.com/s/1nu2Suwh
三.快捷注释代码
添加一些配置文件宏,比如:注释掉代码:单行注释、多行注释,将选中内容注释掉;在一行代码的前、后添加注释性文字等。
打开Projcet->Open project,选择base,可以看到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)  //取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)  
}

四.删除中文退格键
*① 复制入SourceInsight安装目录;
* ② Project→Open Project,打开Base项目;
* ③ 将复制过去的SuperBackspace.em添加入Base项目;
* ④ 重启SourceInsight;
* ⑤ Options→Key Assignments,将Marco: SuperBackspace绑定到BackSpace键;
* ⑥ Enjoy!!

macro SuperBackspace()
    {
    hwnd = GetCurrentWnd();
    hbuf = GetCurrentBuf();

    if (hbuf == 0)
        stop;   // empty buffer

    // get current cursor postion
    ipos = GetWndSelIchFirst(hwnd);

    // get current line number
    ln = GetBufLnCur(hbuf);

    if ((GetBufSelText(hbuf) != "") || (GetWndSelLnFirst(hwnd) != 
    GetWndSelLnLast(hwnd))) {
        // sth. was selected, del selection
        SetBufSelText(hbuf, " "); // stupid & buggy sourceinsight :(
        // del the " "
        SuperBackspace(1);
        stop;
    }

    // copy current line
    text = GetBufLine(hbuf, ln);

    // get string length
    len = strlen(text);

    // if the cursor is at the start of line, combine with prev line
    if (ipos == 0 || len == 0) {
        if (ln <= 0)
            stop;   // top of file
        ln = ln - 1;    // do not use "ln--" for compatibility with older 
versions
        prevline = GetBufLine(hbuf, ln);
        prevlen = strlen(prevline);
        // combine two lines
        text = cat(prevline, text);
        // del two lines
        DelBufLine(hbuf, ln);
        DelBufLine(hbuf, ln);
        // insert the combined one
        InsBufLine(hbuf, ln, text);
        // set the cursor position
        SetBufIns(hbuf, ln, prevlen);
        stop;
    }

    num = 1; // del one char
    if (ipos >= 1) {
        // process Chinese character
        i = ipos;
        count = 0;
        while (AsciiFromChar(text[i - 1]) >= 160) {
            i = i - 1;
            count = count + 1;
            if (i == 0)
                break;
        }
        if (count > 0) {
            // I think it might be a two-byte character
            num = 2;
            // This idiot does not support mod and bitwise operators
            if ((count / 2 * 2 != count) && (ipos < len))
                ipos = ipos + 1;    // adjust cursor position
        }
    }

    // keeping safe
    if (ipos - num < 0)
        num = ipos;

    // del char(s)
    text = cat(strmid(text, 0, ipos - num), strmid(text, ipos, len));
    DelBufLine(hbuf, ln);
    InsBufLine(hbuf, ln, text);
    SetBufIns(hbuf, ln, ipos - num);
    stop;
}
/*

你可能感兴趣的:(效率软件)