Sublime Text 3 插入当前日期及时间
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")
}
)
Sublime Text 3 是我平时最喜欢的 Coding 工具,没有之一,可以通过 Python 来 DIY 编写很多插件
打开 Sublime Text 3,点击菜单栏中 Preferences -> Browser Packages...

会弹出资源管理器,进入 User 文件,新建一个名为 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")
-
}
-
)
在 Sublime Text 3 的菜单栏中点击 Preferences -> Key Bindings

在弹出窗口右边栏添加以下内容:
-
[
-
{ "keys": ["ctrl+shift+,"], "command": "add_current_time" },
-
]
以后要输入当前日期及时间,按组合键 Ctrl + Shift + ,即可
浙公网安备 33010602011771号