可以通过py脚本,快速插入格式化的当前日期时间,步骤如下:
1、编写py脚本
点击 Perferences -- Browse Packages... 打开文件夹

进入文件夹 User

在User 文件夹下新增文件 insert_current_time.py

在insert_current_time.py 文件里输入:
import datetime
import sublime_plugin
class InsertCurrentTime(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")
}
)
2、设置快捷键
点击 Perferences -- Key Bindings

在弹出的输入框的右侧输入:
[
{ "keys": ["alt+1"], "command": "insert_current_time" },
]
Ctrl+s 保存。
然后 alt+1 就可以快速插入当前日期时间了。
如果不行,就重启一次 Sublime。
网友评论