首先在sublime菜单栏,找到Tools → New Plugin...
删除编辑器自带的代码,然后插入如下代码,
// Sublime Text 3 - sublime text 3 保存的路径
Sublime Text 3\Data\Packages\User\addCurrentTime.py
// such as : windows下的sublime 保存路径例子
D:\SoftwareFiles\SublimeTextBuild_3065_x64\Data\Packages\User\addCurrentTime.py
import datetime
import sublime_plugin
class AddInfoCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("insert_snippet",{
"contents": "/**""\n"
" * @Author: lily ""\n"
" * @DateTime: " "%s" % datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") +"\n"
" */"
})
然后在设置用户自定义快捷键,如下路径** Preference → Key Bindings - User **
// 在原有的配置文件上增加如下:( 可能需要添加 ',' )
{ "keys": ["ctrl+shift+,"], "command": "add_info" }
网友评论