zoukankan      html  css  js  c++  java
  • slickedit的alias配置

    使用slickedit很喜欢它的多语言支持,可以快速查看变量的定义和结构。我一般写verilog较多,使用emcas很方便,但是感觉查看代码结构不太方便(也可能是我不会设置)。所以希望能够在slickedit上实现一些在emacs上很实用的技巧。好在slickedit支持slick-C,可以很方便的支持一些alias操作来帮助写代码。

    文件头注释

    文件头注释用到很多,我喜欢在里面标注文件名、工程名、简要描述信息以及修改日期。

       一个例子如下所示:

     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中调用这些函数即可。

    • 用到的Slick-C函数
     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 }
    • 创建一个global-alias,命名为fileh,代码为
     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%的格式。

    改进

    使用时感觉还需要对它再进一步改进,添加一个命令,让代码每次修改后能够更新一个时间tag,并且修改Last modified时间标记。

    添加一个文件更新alias,命名为fileup

    1 %m find_tag1%%m _get_date%%s

    注意alias中的代码并不是以函数顺序执行,而是直接执行类似于替换的操作,所有这里要放在一行,否则会导致多余的换行。

    然后新建一个user_macro.e文件,将用到的slick-C函数代码实现在文件中,如下:

     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下会多一行,显示最后更改代码的时间。

    后续计划继续摸索slickedit中的alias,多编写一些实用的类似template的功能。

  • 相关阅读:
    修复 Visual Studio Error “No exports were found that match the constraint”
    RabbitMQ Config
    Entity Framework Extended Library
    Navisworks API 简单二次开发 (自定义工具条)
    NavisWorks Api 简单使用与Gantt
    SQL SERVER 竖表变成横表
    SQL SERVER 多数据导入
    Devexpress GridControl.Export
    mongo DB for C#
    Devexress XPO xpPageSelector 使用
  • 原文地址:https://www.cnblogs.com/chenbei-blog/p/4831967.html
Copyright © 2011-2022 走看看