源码阅读SourceInsight

来源:互联网 发布:mac装win7未能启动 编辑:程序博客网 时间:2024/06/05 05:02

一、创建项目。

二、字体设置。

打开SourceInsight, 在菜单栏中点击Options-->Document Options

A、Screen fonts 设置字体为Times New Roman, 常规, 五号。

 

B、显示行号, 勾选右下角show line numbers。

 

三、注释相关宏定义

1Open project “base”, add the follow content to the file utiles.em

//add  or remove "//"  to each line; 定义快捷键为Ctrl+/

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)

}

//add or remove "#if 0" to the begin and  "#endif"  to the end of content;  定义快捷键为Ctrl+#

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 )

}

 

 

// add or remove "/*" to the begin , "*/" to the end of the content; 定义快捷键为Ctrl+*

macro CommentSelStr()

{

    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 == "/*" && szIfEnd == "*/") {

            DelBufLine(hbuf, lnLast+1)

            DelBufLine(hbuf, lnFirst-1)

            sel.lnFirst = sel.lnFirst - 1

            sel.lnLast = sel.lnLast  - 1

    }else{

            InsBufLine(hbuf, lnFirst, "/*")

            InsBufLine(hbuf, lnLast+2, "*/")

            sel.lnFirst = sel.lnFirst + 1

            sel.lnLast = sel.lnLast + 1

    }

 

    SetWndSel( hwnd, sel )

}

2add fast key

Options-> key assignments->assign New Key…->OK

 

 

四、删除行快捷键。

 

五、搜索快捷键

Ctrl+f

F3F4上下跳转

File…按钮可进入整个项目搜索,需要勾选project wide

 

 

六、快速跳转行

F5

 

 

七、代码排版

利用AStyle插件进行排版。

代码风格http://astyle.sourceforge.net/astyle.html#_default_bracket_style

AStyle工具下载,目前最新版为AStyle_2.06_windows.zip

下载网址http://astyle.sourceforge.net/

步骤

1、工具包解压后,找到AStyle.exe放到安装目录下

C:\Program Files\Source Insight 3

2、添加Option-custom commands里面

命令名称AStyle

Run  "C:\Program Files\Source Insight 3\AStyle.exe"  --style=bsd %f

这里的--style=bsd可以换成--style=java

 

3、添加快捷键ctrl+shift+p

 

原创粉丝点击