Sublime Text 插入头部注释插件【Verilog Gadget/File Header】

1、Verilog Gadget插件

1.1、安装

直接在 Install Package工具栏安装即可。

1.2、使用【只针对.v或者.sv文件】

在写Verilog中除了需要代码补齐外,还需要的一个功能是自动生成例化模板和自动生成可供仿真使用的TestBeach,对于输入输出信号多的模块而言尤为重要,而插Verilog Gadge恰好具有这个功能。
其他功能不在介绍,直接说插入头部注释功能,安装完成之后,在sublime text编辑代码界面右键可以弹出如下窗口:
image
鼠标选中之后,直接左键即可!而如何编辑头部注释内容,见如下:[见verilog_header.v]

直接编辑verilog_header.v文件即可

// This is a simple example.
// You can make a your own header file and set its path to settings.
// (Preferences > Package Settings > Verilog Gadget > Settings - User)
//
// "header": "Packages/Verilog Gadget/template/verilog_header.v"
//
// -----------------------------------------------------------------------------
// Copyright (c) 2014-{YEAR} All rights reserved
// -----------------------------------------------------------------------------

例如本文编辑如下:[其他的可以自己多去参考!]

// -----------------------------------------------------------------------------
// Author: 
// Create: {DATE} {TIME}
// Revise: {RDATE} {RTIME}

// File   Name: verilog_header.v
// Module Name:
// Editor Desc: sublime text{SUBLIME_VERSION}, tab size ({TABS})
/* Description:

*/

/* Remark:

*/
// -----------------------------------------------------------------------------

1.3、参考

Sublime与Verilog【二】:几款提升搬砖效率的插件!

2、File Header插件

2.1、安装

直接在 Install Package工具栏安装即可。

2.2、使用

File Header是一款非常优秀的插件,支持很多语言插入头部注释【创建文件即自动插入\或者手动插入】

主要特性

  • 不仅支持创建已经使用模板初始化好的文件,而且支持将header添加到已经存在的文件头部,并且支持批量添加;
  • 几乎支持所有的编程语言,并且支持用户自定义语言;
  • 能够自动的更新文件最后修改时间;【非常好】
  • 能够自动的更新文件最后的修改者,这在协同开发中是一个很有用的功能;
  • 将一个模板文件分为header和body两部分。允许用户自定义自己的模板文件。

点击Preferences,选择Browse Packages,找到FileHeader文件夹——template文件夹——header文件夹——修改里面的.tmpl后缀文件
以修改c.tmpl文件为例:

/*
* @Author: {{author}}
* @Date:   {{create_time}}
* @Last Modified by:   {{last_modified_by}}
* @Last Modified time: {{last_modified_time}}
*/

给出自己的模板:

// -----------------------------------------------------------------------------
// Author:
// Create: {{create_time}}
// Revise: {{last_modified_time}}

// File   Name: {{file_name}}
// Module Name:
/* Description:

*/

/* Remark:

*/
// -----------------------------------------------------------------------------

一定要双括号修改,可以修改的内容见File Headers的settings-default:

"Default": {
        /*
        Builtin Variables
        =================

        - create_time

            The file created time. It will be automatically set when you create
            a new file if you use it.

            Can't be set custom.

        - author

            The file creator.

            FileHeader will set it automatically. If it's in
            a git repository and the `user.name` has been set, `autor`
            will set to `user.name`, otherwise it will be set to current
            system user.

            Can be set custom.

        - last_modified_by

            The file last modified by who? It is specially useful when
            cooperation programming.

            FileHeader will set it automatically. If it's in
            a git repository and the `user.name` has been set, `autor`
            will set to `user.name`, otherwise it will be set to current
            system logined user.

            Can be set custom.

        - last_modified_time

            The file last modified time.

            FileHeader will set it automatically when you save the file.

            Can't be set custom.

        - file_path

            The absolute path of the current file.

            FileHeader will update it automatically when you change it.

            Can't be set custom.

        - file_name

            The name of current file with extension.

            FileHeader will update it automatically when you change it.

            Can't be set custom.

        - file_name_without_extension

            The name of current file without extension.

            FileHeader will update it automatically when you change it.

            Can't be set custom.

        - project_name

            The project name.

            Note: `project_name` only works in ST3.

            Can't be set custom.
        */

也可以自己在settings-default中添加内容:

{
    "Default":{
        "email":"xxxx@qq.com",
        "last_modified_by":"张三",
        "author":"张三"
    }
}

具体使用如下:可以代码编辑区鼠标右键选择,也可以选中文件之后右键选择!
image

2.3、扩展其他语言或者头文件

当在新建 .h / .hpp 文件时,发现并没有生成对应的头部注释信息,那么要怎么办呢?

其实只需要简单的修改一下它的 Python 代码就可以完成这个需求了。

步骤:Preferences -> Browse Packages... -> FileHeader -> FileHeader.py
文件编辑器打开 FileHeader.py 后,找到 FILE_SUFFIX_MAPPING 的映射信息,顾名思义,就是它定义的文件后缀名映射到不同语法的信息。所以,我们如果想要 .h / .hpp 变得像 .c / .cpp 一样;同样道理,可以把.v/.sv文件的头部注释与.c文件一致即可【同一映射】。

可以添加这样两行:

    ... # 省略
    "bat": "Batch File",
    "cmd": "Batch File",
    "c": "C",
    "h": "C", # 添加这一行
    "v": "C", # 添加这一行
    "sv": "C", # 添加这一行
    "cs": "C#",
    "cpp": "C++",
    "hpp": "C++", # 还有这一行
    "clj": "Clojure",
    "css": "CSS",
    "D": "D",
    ... # 省略

直接修改sublime Text\Packages\FileHeaderFileHeader.py文件,添加例如:
image

2.5、参考

posted @ 2023-07-20 03:46  `Konoha  阅读(346)  评论(0编辑  收藏  举报