创建插件
步骤: Sublime 菜单栏->Tools→New Plugin...
点击并将文件保存到指定目录( sublime text 3 安装的路径):
Sublime Text 3DataPackagesUseraddCurrentTime.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"},