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":
" # @Author: Vistar\n"
" # @DateTime: ""%s" %datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + "\n"
" # @Description: Description\n"
}
)
将文件保存到 ../sublime-text-3/Packages/User/
(一般默认目录就是这个),文件名任意。
添加的信息内容按自己需要修改。
2. 创建快捷键
依次选择Preference
→ Key Bindings
→ User
把在文件中的内容修改为以下内容:
[
{
"command": "add_info",
"keys": ["ctrl+shift+."]
}
]
!!!注意!!!
第一步配置文件中的 AddInfoCommand
和第二步文件中的 add_info
要对应。
1 中的为大驼峰命名法,2 中的用下划线命名法,否则快捷键不起作用。