美文网首页
ST编写plugin实现插入时间功能

ST编写plugin实现插入时间功能

作者: 霁纯 | 来源:发表于2016-09-22 16:00 被阅读0次

在st中,Tools->New Plugin,输入如下python代码,保存为addCurrentTime.py

import datetime
import sublime_plugin
class AddCurrentTimeCommand(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") 
            }
        )

再打开Preference->Key Binding-User,输入如下设置

[
    {
        "command": "add_current_time",
        "keys": [
            "ctrl+shift+."
        ]
    }
]

保存即可,这样以后想要插入当前时间时,就按’ctrl+shift+.‘即可

相关文章

网友评论

      本文标题:ST编写plugin实现插入时间功能

      本文链接:https://www.haomeiwen.com/subject/qrmzettx.html