很奇怪为什么强大的Sublime编辑器为什么没有添加当前时间的快捷键,不过还好Sublime可以通过自定义插件的方式来实现任何你想要的效果
1. 创建插件:
Tools → New Plugin:
新建文件并 保存为Sublime Text 2PackagesUseraddInfo.py
importdatetime importsublime_plugin classAddInfoCommand(sublime_plugin.TextCommand): defrun(self,edit): self.view.run_command("insert_snippet", { "contents":"/**"" " " * @Author: HTL"" " " * @DateTime: " "%s" %datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+" " " * @Description: Description"" " " */" } )
2. 创建快捷键:
Preference→KeyBindings-User:
[
{
"command":"add_info",
"keys":[
"ctrl+shift+,"
]
}
]
3. 此时使用快捷键ctrl+shift+,即可在当前光标处插入当前你自定义的内容了,如下:
参考: