zoukankan      html  css  js  c++  java
  • sublime text 自定义插件,自动插入署名,自定义插入日期,自动生成头部注释

    自动插入署名

    菜单下面的

    一、工具(tool)>新代码段(new snippet…)

    看到以下代码

    <snippet>
        <content><![CDATA[
    Hello, ${1:this} is a ${2:snippet}.
    ]]></content>
        <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
        <!-- <tabTrigger>hello</tabTrigger> -->
        <!-- Optional: Set a scope to limit where the snippet will trigger -->
        <!-- <scope>source.python</scope> -->
    </snippet>

    1.snippet介绍

    content:其中必须包含<![CDATA[…]]>,否则无法工作, Type your snippet here用来写你自己的代码片段
    tabTrigger:用来引发代码片段的字符或者字符串, 比如在以上例子上, 在编辑窗口输入hello然后按下tab就会在编辑器输出Type your snippet here这段代码片段
    scope: 表示你的代码片段会在那种语言环境下激活, 比如上面代码定义了source.python, 意思是这段代码片段会在python语言环境下激活.
    description :展示代码片段的描述, 如果不写的话, 默认使用代码片段的文件名作为描述

    2.Snippet可以存储在任何的文件夹中, 并且以.sublime-snippet为文件扩展名, 默认是存储在.sublime-snippet文件夹下。

    二、将以下代码粘贴到文件中

    <snippet>
        <content><![CDATA[
    /**
     * date: ${1:ctrl+alt+shift+d}
     * author: ${2:}
     * descride:${3:}
     */
    ]]></content>
        <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
        <tabTrigger>headmark</tabTrigger>
        <!-- Optional: Set a scope to limit where the snippet will trigger -->
        <!-- <scope>source.python</scope> -->
    </snippet>

    保存的文件后缀是.sublime-snippet 

    在文件里面输入headmark,按tab就可以出来了

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    快速插入日期

    菜单下面的

    一、工具(tool)>新代码段(new plugin…)

    看到以下代码

    import sublime, sublime_plugin
    
    class ExampleCommand(sublime_plugin.TextCommand):
        def run(self, edit):
            self.view.insert(edit, 0, "Hello, World!")

    将以下代码粘贴进去

    import datetime, getpass
    import sublime, sublime_plugin
    class AddDateTimeStampCommand(sublime_plugin.TextCommand):
        def run(self, edit):
            self.view.run_command("insert_snippet", { "contents": "%s" %  datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") } )
    class AddDateStampCommand(sublime_plugin.TextCommand):
        def run(self, edit):
            self.view.run_command("insert_snippet", { "contents": "%s" %  datetime.datetime.now().strftime("%Y-%m-%d") } )
    class AddTimeStampCommand(sublime_plugin.TextCommand):
        def run(self, edit):
            self.view.run_command("insert_snippet", { "contents": "%s" %  datetime.datetime.now().strftime("%H:%M:%S") } )

    保存的文件后缀是.py 

    二、自定义快捷键

    preferences>键绑定-用户

    [
        {"keys": ["ctrl+alt+shift+d"], "command": "add_date_time_stamp" },
        {"keys": ["ctrl+alt+d"], "command": "add_date_stamp" },
        {"keys": ["ctrl+alt+t"], "command": "add_time_stamp" }
    ]

    保存就可以了使用了

  • 相关阅读:
    试验thrift做后端rpc,nginx做web服务器, python后端php前端
    DBSCAN算法
    用VAE(variational autoencoder)做sentence embedding/representation或者其他任何结构数据的热presentation
    关于rnn神经网络的loss函数的一些思考
    神经网络建模的一些感悟;
    embedding based logistic regression-神经网络逻辑回归tensorflow
    Farseer.net轻量级开源框架说明及链接索引
    什么是表达式树,它与表达式、委托有什么区别?(1)
    Farseer.net轻量级ORM开源框架 V1.x 教程目录
    Farseer.net轻量级ORM开源框架 V1.8版本升级消息
  • 原文地址:https://www.cnblogs.com/wangzhaobo/p/8862473.html
Copyright © 2011-2022 走看看