使用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的功能。