使用slickedit很喜歡它的多語言支持,能夠快速查看變量的定義和結構。我通常寫verilog較多,使用emcas很方便,可是感受查看代碼結構不太方便(也多是我不會設置)。因此但願可以在slickedit上實現一些在emacs上很實用的技巧。好在slickedit支持slick-C,能夠很方便的支持一些alias操做來幫助寫代碼。session
文件頭註釋用到不少,我喜歡在裏面標註文件名、工程名、簡要描述信息以及修改日期。ide
一個例子以下所示:函數
1 //----------------------------------------------------------------------------- 2 // File : wave.c 3 // Project : test 4 // Author : chenbei <chenbei@rigol.com> 5 // Created : 2015-09-23 6 // Last modified : 2015-09-23 7 //----------------------------------------------------------------------------- 8 // Description : 9 // 測試 10 //----------------------------------------------------------------------------- 11 // Copyright (c) by Rigol This model is the confidential and 12 // proprietary property of Rigol and the possession or use of this 13 // file requires a written license from Rigol. 14 //------------------------------------------------------------------------------ 15 // Modification history : 16 // 2015-09-23 : created 17 //-----------------------------------------------------------------------------
要方便的建立這個文件註釋,須要編寫一些slick-C函數,而後在alias中調用這些函數便可。測試
1 // 獲取當前文件名,參數'PD'表示從獲取的完整文件名中去掉Path和Directory,保留Extension和Name 2 _str _get_file_name( ){ 3 _str file_name = _strip_filename( p_buf_name, 'PD' ); 4 return file_name; 5 } 6 7 // 獲取當前日期,參數'I'表示按照標準 yy-mm-dd 格式 8 _str _get_date( ){ 9 _str date = _date( 'I' ); 10 return date; 11 }
1 //----------------------------------------------------------------------------- 2 // File : %\m _get_file_name% 3 // Project : %(project) 4 // Author : chenbei <chenbei@rigol.com> 5 // Created : %\m _get_date% 6 // Last modified : %\m _get_date% 7 //----------------------------------------------------------------------------- 8 // Description : 9 // %(file_desc) 10 //----------------------------------------------------------------------------- 11 // Copyright (c) by Rigol This model is the confidential and 12 // proprietary property of Rigol and the possession or use of this 13 // file requires a written license from Rigol. 14 //------------------------------------------------------------------------------ 15 // Modification history : 16 // %\m _get_date% : created 17 //-----------------------------------------------------------------------------
注意調用函數時,使用%\m _func%的格式。ui
使用時感受還須要對它再進一步改進,添加一個命令,讓代碼每次修改後可以更新一個時間tag,而且修改Last modified時間標記。this
添加一個文件更新alias,命名爲fileupspa
1 %\m find_tag1%%\m _get_date%%\s
注意alias中的代碼並非以函數順序執行,而是直接執行相似於替換的操做,全部這裏要放在一行,不然會致使多餘的換行。code
而後新建一個user_macro.e文件,將用到的slick-C函數代碼實如今文件中,以下:blog
1 // 獲取當前文件名,參數'PD'表示從獲取的完整文件名中去掉Path和Directory,保留Extension和Name 2 _str _get_file_name( ){ 3 _str file_name = _strip_filename( p_buf_name, 'PD' ); 4 return file_name; 5 } 6 7 // 獲取當前日期,參數'I'表示按照標準 yy-mm-dd 格式 8 _str _get_date( ){ 9 _str date = _date( 'I' ); 10 return date; 11 } 12 13 // 獲取Last modified字符串,定位日期位置 14 void find_tag1 ( ) { 15 find_tag2 ( ); //先定位 16 find( 'Last modified : ' ); 17 cut_word(); //刪除原來的時間信息(three word) 18 cut_word(); 19 cut_word(); 20 } 21 22 // 獲取modification history字符串位置 23 void find_tag2 ( ) { 24 find( 'Modification history :' ); 25 _str a[ ]; 26 a[0] = '//'; 27 a[1] = _get_date( ); 28 a[2] = ': modified by chenbei'; 29 _str com = join( a, ' ' ); //使用空格字符鏈接三個字符串,構成一行 30 insert_line( com ); 31 }
當編輯完代碼,須要更新文件頭註釋的時候,只須要在代碼任意新一行輸入 "fileup」而後按alias expansion快捷鍵便可將當前時間更新到文件頭註釋中去,在Modified history下會多一行,顯示最後更改代碼的時間。three
後續計劃繼續摸索slickedit中的alias,多編寫一些實用的相似template的功能。