创建Sublime插件

创建插件

步骤: Sublime 菜单栏->Tools→New Plugin...
点击并将文件保存到指定目录( sublime text 3 安装的路径):

Sublime Text 3\Data\Packages\User\addCurrentTime.py

插件内容:

import datetime
import sublime, 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 Bindings - User
在原有的配置文件上增加如下:

{ "keys": ["alt+t"],"command": "add_current_time"},
posted @ 2017-10-27 20:49  oneVillager  阅读(134)  评论(0编辑  收藏  举报
打赏

喜欢请打赏

扫描二维码打赏