source insight 使用技巧

轉自:http://blog.csdn.net/tony821224/archive/2008/09/26/2982685.aspx

 

在Source Insight中添加自定義功能的步驟如下:
1.Source Insight中,Options->Custom Commands...->Add...,New Command name 隨便寫,我的是"Edit with Vim" 
2.Run中寫入: "C:/Program Files/Vim/vim63/gvim.exe" --remote-silent +%l %f 
意思是在當前已經打開的gvim窗口裏面打開當前的文件,並且跳轉到指定行 
%l爲當前的行號,%f爲文件名 
使用 --remote-silent 的作用是,如果已經打開了對應文件,就不會打開第二次,而是在已經打開的文件裏跳轉到對應行 
3.還是同一個對話框裏面,選擇Keys->Assign New Key...->按F12,如果你已經將F12設置給其他命令,選擇其他的按鍵就行了

下面是一些常用自定義功能:( CUSTOM COMMANDS )

打開資源管理器並選中當前文件
ShellExecute open explorer /e,/select,%f
查看log
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:log /path:%f /notempfile /closeonend
diff
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:diff /path:%f /notempfile /closeonend
取得鎖定(check out)
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:lock /path:%f /notempfile /closeonend
提交(check in)
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:commit /path:%f /notempfile /closeonend
更新(update)
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:update /path:%f /notempfile /closeonend
更新整個目錄(update all)
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:update /path:*.* /notempfile /closeonend
取消鎖定(undo check out)
"C:/Program Files/TortoiseSVN/bin/TortoiseProc.exe" /command:revert /path:%f /notempfile /closeonend
在ultriEdit中編輯
"C:/Program Files/UltraEdit-32/uedit32" %f
在vim中編輯並定位到當前行
"C:/Program Files/Vim/vim63/gvim.exe" --remote-silent +%l %f 

彙總其他小技巧:

讓{ 和 } 不縮進:

Options->Document Options->Auto Indent->Indent Open Brace/Indent Close Brace

hao space: SourceInsight 小技巧
1、按住"ctrl", 再用鼠標指向某個變量,點擊一下,就能進入這個變量的定義。
 
2、今天把一個用sourceinsight排版整齊的C文件,偶然用VC打開一看,全亂了。研究了半天,發現SI對每個字符的寬度不太一致。
    請教同事發現選上"view --> draft view", 就可以讓每個字符的寬度一致了。快捷鍵是 "Alt + F12"
 
3、"shift+F8" 標亮所有文本中光標所在位置的單詞
 
4、跳到某一行:"ctrl + g"

 

 Source Insight是閱讀和編寫代碼的好東東,基本上也算得上是經典之作了,雖然還有一點點小bug,不過對於我們這些C程序員來說可是一旦擁有別無所求。下列小技巧是在工作中同事整理總結的,對提高工作效率多少有點幫助,其中有些是對應於SVN的,沒有使用SVN做版本管理的人就不要白費力氣了。

ShellExecute open explorer /e,/select,%f
        /*作用是在資源管理器中打開當前編輯文件並選中*/
        /*可以設置快捷鍵如ctrl+e,這樣能很方便的在資源管理器打開對應的文件,並進行tortoiseSVN的相關操作*/

X:/Progra~1/TortoiseSVN/bin/TortoiseProc.exe /command:log /path:% /notempfile /closeonend
        /*使用前注意更改對應的bin安裝路徑*/
        /*作用是直接查看當前文件的svn log*/
        /*可以設置快捷鍵如ctrl+l*/

X:/Progra~1/TortoiseSVN/bin/TortoiseProc.exe /command:diff /path:% /notempfile /closeonend
        /*使用前注意更改對應的bin安裝路徑*/
        /*作用是直接查看當前文件和基準版本的比較*/
        /*可以設置快捷鍵如ctrl+d*/

在Source Insight中快速添加註釋
      將以下代碼保存成Utils.em,詳細使用說明看文章結尾

/* Utils.em - a small collection of useful editing macros */

/*-------------------------------------------------------------------------
    I N S E R T   H E A D E R

    Inserts a comment header block at the top of the current function. 
    This actually works on any type of symbol, not just functions.

    To use this, define an environment variable "MYNAME" and set it
    to your email name.  eg. set MYNAME=raygr
-------------------------------------------------------------------------*/
macro InsertHeader()
{
    // Get the owner's name from the environment variable: MYNAME.
    // If the variable doesn't exist, then the owner field is skipped.
    szMyName = getenv(MYNAME)
    
    // Get a handle to the current file buffer and the name
    // and location of the current symbol where the cursor is.
    hbuf = GetCurrentBuf()
    szFunc = GetCurSymbol()
    ln = GetSymbolLine(szFunc)

    // begin assembling the title string
    sz = "/*   "
    
    /* convert symbol name to T E X T   L I K E   T H I S */
    cch = strlen(szFunc)
    ich = 0
    while (ich < cch)
        {
        ch = szFunc[ich]
        if (ich > 0)
            if (isupper(ch))
                sz = cat(sz, "   ")
            else
                sz = cat(sz, " ")
        sz = Cat(sz, toupper(ch))
        ich = ich + 1
        }
    
    sz = Cat(sz, "   */")
    InsBufLine(hbuf, ln, sz)
    InsBufLine(hbuf, ln+1, "/*-------------------------------------------------------------------------")
    
    /* if owner variable exists, insert Owner: name */
    if (strlen(szMyName) > 0)
        {
        InsBufLine(hbuf, ln+2, "    Owner: @szMyName@")
        InsBufLine(hbuf, ln+3, " ")
        ln = ln + 4
        }
    else
        ln = ln + 2
    
    InsBufLine(hbuf, ln,   "    ") // provide an indent already
    InsBufLine(hbuf, ln+1, "-------------------------------------------------------------------------*/")
    
    // put the insertion point inside the header comment
    SetBufIns(hbuf, ln, 4)
}


/* InsertFileHeader:

   Inserts a comment header block at the top of the current function. 
   This actually works on any type of symbol, not just functions.

   To use this, define an environment variable "MYNAME" and set it
   to your email name.  eg. set MYNAME=raygr
*/

macro InsertFileHeader()
{
    szMyName = getenv(MYNAME)
    
    hbuf = GetCurrentBuf()

    InsBufLine(hbuf, 0, "/*-------------------------------------------------------------------------")
    
    /* if owner variable exists, insert Owner: name */
    InsBufLine(hbuf, 1, "    ")
    if (strlen(szMyName) > 0)
        {
        sz = "    Owner: @szMyName@"
        InsBufLine(hbuf, 2, " ")
        InsBufLine(hbuf, 3, sz)
        ln = 4
        }
    else
        ln = 2
    
    InsBufLine(hbuf, ln, "-------------------------------------------------------------------------*/")
}



// Inserts "Returns True .. or False..." at the current line
macro ReturnTrueOrFalse()
{
    hbuf = GetCurrentBuf()
    ln = GetBufLineCur(hbuf)

    InsBufLine(hbuf, ln, "    Returns True if successful or False if errors.")
}



/* Inserts ifdef REVIEW around the selection */
macro IfdefReview()
{
    IfdefSz("REVIEW");
}


/* Inserts ifdef BOGUS around the selection */
macro IfdefBogus()
{
    IfdefSz("BOGUS");
}


/* Inserts ifdef NEVER around the selection */
macro IfdefNever()
{
    IfdefSz("NEVER");
}


// Ask user for ifdef condition and wrap it around current
// selection.
macro InsertIfdef()
{
    sz = Ask("Enter ifdef condition:")
    if (sz != "")
        IfdefSz(sz);
}

macro InsertCPlusPlus()
{
    IfdefSz("__cplusplus");
}


// Wrap ifdef <sz> .. endif around the current selection
macro IfdefSz(sz)
{
    hwnd = GetCurrentWnd()
    lnFirst = GetWndSelLnFirst(hwnd)
    lnLast = GetWndSelLnLast(hwnd)
     
    hbuf = GetCurrentBuf()
    InsBufLine(hbuf, lnFirst, "#ifdef @sz@")
    InsBufLine(hbuf, lnLast+2, "#endif /* @sz@ */")
}


// Delete the current line and appends it to the clipboard buffer
macro KillLine()
{
    hbufCur = GetCurrentBuf();
    lnCur = GetBufLnCur(hbufCur)
    hbufClip = GetBufHandle("Clipboard")
    AppendBufLine(hbufClip, GetBufLine(hbufCur, lnCur))
    DelBufLine(hbufCur, lnCur)
}


// Paste lines killed with KillLine (clipboard is emptied)
macro PasteKillLine()
{
    Paste
    EmptyBuf(GetBufHandle("Clipboard"))
}



// delete all lines in the buffer
macro EmptyBuf(hbuf)
{
    lnMax = GetBufLineCount(hbuf)
    while (lnMax > 0)
        {
        DelBufLine(hbuf, 0)
        lnMax = lnMax - 1
        }
}


// Ask the user for a symbol name, then jump to its declaration
macro JumpAnywhere()
{
    symbol = Ask("What declaration would you like to see?")
    JumpToSymbolDef(symbol)
}

    
// list all siblings of a user specified symbol
// A sibling is any other symbol declared in the same file.
macro OutputSiblingSymbols()
{
    symbol = Ask("What symbol would you like to list siblings for?")
    hbuf = ListAllSiblings(symbol)
    SetCurrentBuf(hbuf)
}


// Given a symbol name, open the file its declared in and 
// create a new output buffer listing all of the symbols declared
// in that file.  Returns the new buffer handle.
macro ListAllSiblings(symbol)
{
    loc = GetSymbolLocation(symbol)
    if (loc == "")
        {
        msg ("@symbol@ not found.")
        stop
        }
    
    hbufOutput = NewBuf("Results")
    
    hbuf = OpenBuf(loc.file)
    if (hbuf == 0)
        {
        msg ("Can't open file.")
        stop
        }
        
    isymMax = GetBufSymCount(hbuf)
    isym = 0;
    while (isym < isymMax)
        {
        AppendBufLine(hbufOutput, GetBufSymName(hbuf, isym))
        isym = isym + 1
        }

    CloseBuf(hbuf)
    
    return hbufOutput

}

/*

    written by yubind

                                                            */

macro SingleLineComment()
{
 szMyName = "chenjsa"
 // Get a handle to the current file buffer and the name
 // and location of the current symbol where the cursor is.
 hbuf = GetCurrentBuf()
 ln = GetBufLnCur(hbuf)

 // Get current time
 szTime = GetSysTime(1)
 Hour = szTime.Hour
 Minute = szTime.Minute
 Second = szTime.Second
 Day = szTime.Day
 Month = szTime.Month
 Year = szTime.Year
 if (Day < 10)
  szDay = "0@Day@"
 else
  szDay = Day
 //szMonth = NumToName(Month)
 if (Month < 10)
     szMonth = "0@Month@"
 else
  szMonth = Month
 
 szDescription = Ask("請輸入修改原因")
 // begin assembling the title string
 InsBufLine(hbuf, ln+1, "/*@szDescription@ @[email protected] @Year@-@szMonth@-@szDay@*/")
}

macro MultiLineCommentHeader()
{
 szMyName = "chenjsa"
 // Get a handle to the current file buffer and the name
 // and location of the current symbol where the cursor is.
 hbuf = GetCurrentBuf()
 ln = GetBufLnCur(hbuf)

 // Get current time
 szTime = GetSysTime(1)
 Hour = szTime.Hour
 Minute = szTime.Minute
 Second = szTime.Second
 Day = szTime.Day
 Month = szTime.Month
 Year = szTime.Year
 if (Day < 10)
  szDay = "0@Day@"
 else
  szDay = Day
 //szMonth = NumToName(Month)
 if (Month < 10)
     szMonth = "0@Month@"
 else
  szMonth = Month
 
 szDescription = Ask("請輸入修改原因:")
 // begin assembling the title string
 InsBufLine(hbuf, ln + 1, "/*@szDescription@ @[email protected] @Year@-@szMonth@-@szDay@ begin*/")
}

macro MultiLineCommentEnd()
{
 szMyName = "chenjsa"
 // Get a handle to the current file buffer and the name
 // and location of the current symbol where the cursor is.
 hbuf = GetCurrentBuf()
 ln = GetBufLnCur(hbuf)

 // Get current time
 szTime = GetSysTime(1)
 Hour = szTime.Hour
 Minute = szTime.Minute
 Second = szTime.Second
 Day = szTime.Day
 Month = szTime.Month
 Year = szTime.Year
 if (Day < 10)
  szDay = "0@Day@"
 else
  szDay = Day
 //szMonth = NumToName(Month)
 if (Month < 10)
     szMonth = "0@Month@"
 else
  szMonth = Month
 
 InsBufLine(hbuf, ln + 1, "/*@[email protected] @Year@-@szMonth@-@szDay@ end*/")
}

使用說明:可以實現在sourceinsight中快速添加修改註釋。

    1. Project->Open Project... 打開Base工程(該工程一般在我的文檔//Source Insight//Projects//Base中);
    2. 搜索utils.em 裏的字串"chenjsa" 改成自己的姓名
    3. Project->Add and Remove Project Files... 加入宏文件(即utils.em);
    4. Options->Menu Assignments 打開Menu Assignments窗口, 在Command中輸入Macro, 選中要使用的宏(SingleLineComment ,MultiLineCommentHeader,MultiLineCommentEnd), 添加到合適的菜單中.

 

 

 

 

 

1 開胃菜-初級應用 
1.1 選擇美麗的界面享受工作 
雖然不能以貌取人,但似乎從來沒有人責備以貌取軟件的。SI的華麗界面,絕對符合現代花花世界的人的審美趣味。在SI中,我們可以輕鬆地把各種類型關鍵字、變量、標誌符、函數、宏、註釋等定義爲不同的顏色和顯示方式(正體或斜體、加粗或正常、加下劃線、放大顯示等),總有一種方式能讓我們一眼就能分辨出這個標識是什麼。 
1.1.1 字體選擇 
在SI中樣式是可以被繼承,如果要從根本上改變字體,最簡單的方式就是直接修改根樣式中的字體,因爲其它樣式都會由此繼承而來。選擇Options/Document Options頁面內的Font Options中的Screen Fonts字體,即可改變根樣式中的字體。SI中的默認配置爲Verdana字體,是一種非等寬字體 2 ,爲了使編寫的代碼在各種編輯器中看起來都有良好的對齊效果,這裏強烈建議使用等寬字體,Courier、New Courier和宋體等都是較好的選擇。 
1.1.2 顏色定義 
畢竟這是見仁見智的東西,所以從來沒有統一的標準3。很多人並不喜歡SI提供的默認配置,那麼我們就改吧。選擇Options/Style Properties頁面,就可以在其中修改所有樣式了。選擇等號(=)表示繼承Parent Style,也可以選擇Pick(或者ON/OFF等)去配置一個新值。這完全視乎個人喜好。 
1.1.3 標識符樣式選擇
 
在與 顏色定義 一節同樣的界面內即可完成此項配置。 
1.1.4 背景色選擇 
在希望要改變背景色的窗口點擊鼠標右鍵(假定使用的是右手鼠標 4),選擇上下文菜單的 xxx Window Properties項,然後點擊彈出窗口的Back Color按鈕,即可修改該窗口背景色。對於SI的源碼主窗口,只需選擇上下文菜單的Special Window Color項即可完成背景色修改。 
1.2 配置合理的默認值高效工作 
1.2.1 使用合理的縮進 
我始終認爲最容易獲得認同的是關於這個選項的配置了。選擇Options/Document Options頁面,點擊其內的Auto Indent按鈕,在彈出的Auto Indenting窗口中,默認配置爲 Auto Indent Type選擇Smart,且勾選了Smart Indent Options中的兩個可選項,這樣得到的默認縮進效果爲[pre]   while (1) 




[/pre]每次都要手工去調整其縮進,其實只要把兩個勾選項去掉,就可以得到[pre]   while (1) 




[/pre]何樂而不爲呢? 
1.2.2 顯示座標 
通常情況下在窗口狀態欄左下方,最會顯示當前光標所在行列信息,但我總覺得不夠明顯,於是通常我們作如下配置: 選擇Options/Document Options頁面,勾選其中的Show line numbers。同時勾選其中的Show right margin,我們就可顯示一條右邊界,隨時提醒我們是否該行代碼寫得過長了。 
1.3 創建便捷的快捷鍵快樂工作 
1.3.1 幾個較常用的快捷鍵 
默認情況下,SI已經定義了很多非常實用的快捷鍵: 

  • F5 
    指定行號,實現行跳轉,在遇到編譯錯誤的時候,能特別方便的找到出錯行。
  • Shift+F8 
    高亮顯示指定標識,快速瀏覽標識的使用情況。
  • Ctrl+鼠標點擊標識 
    直接跳轉至標識定義處。
  • Ctrl+F 
    本文件內查找。
  • F3 
    本文件查找結果的上一個。
  • F4 
    本文件查找結果的下一個。
  • F7 
    打開Browse Project Symbols窗口,快速瀏覽工程內標識定義。
  • Ctrl+M 
    創建或查找書籤,方便下次找回此位置。

1.3.2 自定義快捷健 
選擇Options/Key Assignments,在彈出的Key Assignments窗口中可自由添加自己喜歡的快捷鍵。比較值得推薦的有如下幾個快捷鍵定義:

  • Edit: Drag Line Down 
    光標當前行下移。
  • Edit: Drag Line Up 
    光標當前行下移。
  • Edit: Join Lines 
    當前行和下一行連接成一行。

1.3.3 更多的快捷鍵 
如果你正好對SI的Marco語言(下文將會介紹)有研究,那麼還可以定義更多有用的快捷鍵,比如添加文件頭、函數頭、註釋等(下文在介紹Marco語言時會介紹如何實現)。 
2 小技巧-中級應用 
2.1 查找與替換 
在SI中支持多種查找及替換方式,除了上文提到的文件內查找外,還支持工程範圍內查找、目錄查找、指定多文件查找等等。 
2.1.1 查找 

[list=1]

Loopup References 
我們最常用的一種查找方式是選擇Search/Lookup References或按Ctrl+/組合鍵再或者鼠標點 R 按鈕,在彈出的Loopup References窗口進行查找操作。 在Search Method中有四種可選的查找方式:Simple String、Regular Expression、 Keyword Expression和Look Up Reference。其中Simple String是最普通的查找方式,可以查找文件中出現的任意字符或字符,甚至可以查找 _upap || u 這樣的字符串,但是在工程較大時,查找過程會較慢。 Regular Expression查找方式將在後面講述正則表達時會介紹到,這裏暫時按下不表。 Keyword Expression和Look Up Reference查找的結果基本相同,但是顯示方式略有差異。這兩種方式都是使用SI預先建立的數據庫,查找起來速度相當快。但通常這種速度只對在查找標識符時有明顯效果。對於像函數名,變量名等的查找,強烈建議使用這兩種方式進行查找。 Search Files 
選擇Search/Search Files或按Ctrl+Shift+F組合鍵,在彈出的Search Files窗口進行查找操作。 在File Name框中可以填入文件名或文件夾。注意當要查詢的文件夾雙包含子文件夾時,可以勾選Options中的Include Subdirectiories,實現對各層文件的遞歸搜索。 Search Project 
選擇Search/Search Project,在彈出的Search Project窗口進行查找操作。操作與Loopup References幾乎完全一致,它們各自保存上次搜索的配置。2.1.2 替換 
[list=1] 單文件替換 
選擇Search/Replace或按Ctrl+H組合鍵,在彈出的Replace窗口進行查找操作。在Search項目裏勾選Selection則僅對當前選中的文檔部分進行替換。另外如果勾選了Confirm Replacements則是逐個確認替換,否則會同時替換所有符合替換條件內容。 多文件替換 
選擇Search/Replace Files或按Ctrl+Shift+H組合鍵,在彈出的Replace Files 窗口進行查找操作。除了增加New框(替換後的內容)外,其餘均與Search Files窗口相同,可參照查找部分的說明進行操作。2.2 列操作 
雖然開篇時就說過,SI的列操作功能比較弱,但不等於沒有。先按下Alt鍵,接着就可用鼠標進行列選擇,然後就可以刪除指定的列。 
2.3 無名技巧 
這裏介紹一些小技巧,大多數情況下我們可以無視它們的存在。但如果我們知道這些,某些時候,會有效提高工作效率。 
  • Smart Rename 
    在上下文件菜單中選Smart Rename或按Ctrl+'組合鍵,即可彈出Smart Rename窗口。它有很強大的功能,但最便捷的使用方式是更改函數內局部變量的名字,操作只作用於函數內部,速度非常快。
  • Renumber 
    使用Ctrl+R將彈出Renumber窗口,這個用於處理數字順序排列的情況相當有效,比如數組下標。例如現有代碼 [pre]   array[0] = 1; 
    array[1] = 2; 
    array[2] = 3; 

    [/pre]現在要改爲 [pre]   array[0] = 0; 
    array[1] = 1; 
    array[2] = 2; 
    array[3] = 3; 

    [/pre]當然可以一個個修改,但最快的方式是在array[0] = 1;之前添加array[0] = 0;,然後列選數組下標,使用Renumber功能以 0爲起始值重填數值。
  • Edit Condition 
    很多代碼尤其是驅動代碼,當中有大量的預編譯定義,以實現對不同硬件配置的支持。在閱讀這樣的代碼時最痛苦的是不能簡單判斷程序實際執行的代碼分枝。大量分枝同時存在,常常會混淆我們的視聽。比如對於下面的代碼: [pre]   #ifdef DEV1 
    /* DEV1代碼代碼 */ 
    #else 
    /* 其它設備執行代碼 */ 
    #endif 

    [/pre]如果確定我們當前分析的是DEV1的執行情況 5,那麼可以選擇上下文件菜單的Edit Condition 選項,在彈出的Conditional Parsing窗口中把DEV1的值設置爲True,那麼 #ifdef DEV1就等價於#if 1了,相當註釋掉了#else分枝的代碼。反之,設置爲Flase時,則註釋掉#ifdef DEV1分枝的代碼。
3 學會偷懶-高級應用 
4 附錄1-SI中正則表達式 
由於在查找及替換中,經常會使用用正則表達式6,這裏對SI的正則表達式進行簡單介紹。 
4.1 通配符 
正則表達式通配符總表: 
Character Matches
^ (在表達式開始處) 行的開始部分
. 任意單個字符
[abc] 任意屬於集合 abc 的單個字符
[^abc] 任意不屬於集合 abc 的單個字符
* 前面字符的0個或多個重複
+ 前面字符的1個或多個重複
t 一個 tab 字符
s 一個空格符
w 一個空白符(包括 tab 符和空格符)
$ 行的結束部分
4.2 表達式中的組 
在執行替換操作時,組將大有用武之地。正則表達式的各個部分可以用/(/)進行分隔,分隔得到的每一項就是一個組。在進行替換時可通過組從匹配內容中抽取出特定串。在正則表達式中每個組都有一個編號,自左至右編號從1開始。 例如:abc/(xyx/)將能匹配 abcxyz ,此時組1就包含了 xyz 串。在進行替換操作時,就可以通過在替換後內容框中填入/1來取出這個字符串。推而廣之,可以使用/<number>來取得組<number>所包含的串。 例如:當設定把/(abc/)/(xyz/)替換爲/2/1的替換規則時,對於 abcxyz 被替換串,則組1包含 abc,組2包含 xyz,而替換後的內容定義爲組2內容後跟組1內容(/2/1),因此將得到 xyzabc。 舉個真實的使用例子,相信會增加大家的興趣。有時爲方便調試,代碼中到處流浪着各種形式的mytrace調用[pre]   mytrace("Create parameter list... "); 

[/pre]有時希望把它們全部註釋掉,而有些時候又希望把它們全部恢復回來。這是個簡單的例子,可以使用[pre]   ^/(.*/)/(//*/)/(.*mytrace.*/)/(/*//)___FCKpd___6nbsp;==> /1/3 

[/pre]把它們恢復回來,而使用[pre]   ^/(.*/)/(mytrace/)/(.*/)___FCKpd___7nbsp;==> /1/*/2/3*/ 

[/pre]則完成把它們全部註釋掉。 
5 附錄2-SI中的宏語言 
我始終認爲這是SI中最有趣的部分,這是一種功能強大的編程語言,幾乎可以實現在編程過程可能使用到的各種功能。 這裏不準備對如何實用宏語言進行編程作介紹(可參閱SI幫助文檔。),只介紹如何使用已編好程序。爲方便使用,我已把這些程序都集中放在utils.em文件中,下文就此文件進行論述。 該宏文件實現了一些在編碼過程中可能會用到的功能, 如添加文件頭、函數說明(使用時能自動添加文件名、函數名和當前日期)和宏定義,代碼補全等。 使用說明: 
[list=1] Project/Open Project... 
打開Base工程(該工程一般在"我的文檔/Source Insight/Projects/Base"中); Project/Add and Remove Project Files... 
加入宏文件(即utils.em); Options/Menu Assignments 
打開Menu Assignments窗口,在Command中輸入Macro,選中要使用的宏,添加到合適的菜單中.推薦使用的宏:InsFileHeader、InsFunHeader、InsHeaderDef、InsIfdef和AutoExpand (爲代碼自動補全功能,建議建快捷鍵)。 關於AutoExpand的舉例說明, 當你輸入了 switch 且光標正處於switch後面,運行該宏則會得到[pre]   switch (###) 

case 
break; 
default: 


[/pre]對於InsFunHeader宏,如果有如下函數體[pre]   int nOpenConfigFile(char *pchMemConfig, char *pchFlashConfig, 
int nSize, int nMode) 




[/pre]光標在函數體內時運行該宏,那麼將會在函數體上方得到[pre]/****************************************************************************** 
* nOpenConfigFile - 
* DESCRIPTION:- 

* Input:   N/A 
* Output: N/A 
* Returns: N/A 

* modification history 
* -------------------- 
* 1.00, Apr 19, 2007, T357 written. 
* -------------------- 
******************************************************************************/ 

[/pre]其中的函數名及編寫日期自動按實際情況填充,T357串可通過修改utils.em文件,改成你需要的名字。 
6 附錄3-推薦格式 
所謂人各有志,這裏就不說啦。 
7 結束 
至此,已將我所知的所有關於Source Insight(未包括其附帶的Macro語言)知識在此文檔中描述出來。 如有錯漏,請指正
發佈了20 篇原創文章 · 獲贊 2 · 訪問量 43萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章