红联Linux门户
Linux帮助

Sublime Text添加插入带当前时间说明

发布时间:2014-11-27 10:24:42来源:linux网站作者:木尘

Sublime Text插件实现插入带时间功能的说明:


1.创建插件:

Tools → New Plugin:

import datetime
import sublime_plugin
class AddInfoCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("insert_snippet",
{
"contents": "/**""\n"
" * @Author:      name""\n"
" * @DateTime:    "  "%s"  %datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") +"\n"
" * @Description: Description""\n"
" */"
}
)保存为Sublime Text 2\Packages\User\addInfo.py


2.创建快捷键:

Preference → Key Bindings - User:

[
{
"command": "add_info",
"keys": [
"ctrl+shift+,"
]
}
]


3.此时使用快捷键ctrl+shift+,即可在当前光标处插入当前时间。