jQuery火箭图标返回顶部代码

sublime_Text3中snippet设置信息头(包括作者、日期)

1.tool->new snippet(工具->新代码段) 创建一个新的snippet,并保存为author.sublime-snippet(最好在该目录(User)下再创建一个MySnippet目录):
其内容:

<snippet>
<content><![CDATA[
/**
 * ============================
 * @Author:   XX
 * @Version:  1.0 
 * @DateTime: ${1:ctrl+alt+shift+d}
 * ============================
 */
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>author</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.python</scope> -->
</snippet>

2.Tools → New Plugin(工具->新插件)。创建时间插件,保存在User目录,命名为addCurrentTime.py:
其内容为:

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") } )

3.虽然创建了plugin,但是还需要在sublime编辑器 用户按键–key bindings user(按键绑定-用户)文件里面编辑触发插件的快捷键代码:

[
    {"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" }
]

4.验证。
在sublime Text3中新建一个文件,在文中输入author,然后按Tab键,便可出现信息头,但是时间没有显示,不急,这时候按时间绑定快捷键(ctrl+alt+shift+d)or(ctrl+alt+d)or(ctrl+alt+t),出现不同的日期显示.大功告成!

截图:
这里写图片描述
输入author,然后按Tab键:
这里写图片描述

 

posted @   墨颜丶  阅读(506)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端
点击右上角即可分享
微信分享提示