? ? ? ? source insight 3.5 自帶的一些宏,在安裝目錄下的?utils.em 文件中,用戶也可以自己寫文件,命令為xxx.em ,然后把這個文件添加到項目中即可,添加后在菜單欄?Options -> Key Assignments 里輸入macro 就能顯示新添加的宏名稱,然后給它分配一個快捷鍵,如:
這個新加的宏名如果不顯示,可以先把這個 .em 文件從項目中移除,然后再添加一遍。
新加的宏是這樣的,可以添加到新的一個 xx.em 文件中,加入項目即可。
macro InsertComment2FileHeader()
{hbuf = GetCurrentBuf()//這個是帶絕對路徑的文件名bufFileName = GetBufName(hbuf)nameLen = strlen(bufFileName)//沒找字符串查找的函數,只能用原始方法了ich = 0chPos = nameLenwhile(chPos > 0){ch = bufFileName[chPos - 1]//取文件名,不要路徑,從末尾開始找第一個 "\", 這樣就知道文件名的起點了if(AsciiFromChar(ch) == 92){break}chPos = chPos - 1}realFileName = ""while(chPos < nameLen){//從最后一個"\"開始取就是文件名了ch = bufFileName[chPos]realFileName = cat(realFileName, ch);chPos = chPos + 1}//新加環境變量后,source insight 要關閉再打開才獲取到authorName = getenv(author_email)//參數為0為格林尼治時區,非0為本地時區dateTime = GetSysTime(8)year = dateTime.Yearmonth = dateTime.Monthday = dateTime.Dayhour = dateTime.Hourminute = dateTime.Minutesecond = dateTime.SecondInsBufLine(hbuf, 0, "/*****************************************************************")InsBufLine(hbuf, 1, "* FileName: @realFileName@")InsBufLine(hbuf, 2, "* Description: ")InsBufLine(hbuf, 3, "* DateTime: @year@-@month@-@day@ @hour@:@minute@:@second@")InsBufLine(hbuf, 4, "* Author: @authorName@")InsBufLine(hbuf, 5, "* Version: ")InsBufLine(hbuf, 6, "*****************************************************************/")InsBufLine(hbuf, 7, " ")
}
另外這個環境變量是新加的,添加的是系統級的環境變量,加完之后需要重啟一下 source insight,否則取不到新加的環境變量。效果如下:
?
?