- import datetime
- import sublime_plugin
- class AddCurrentTimeCommand(sublime_plugin.TextCommand):
- def run(self, edit):
- self.view.run_command("insert_snippet",
- {
- "contents": "--[[--""\n"
- " * @Description: ${1:Description}""\n"
- " * @Author: JuhnXu""\n"
- " * @DateTime: " "%s" %datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") +"\n"
- " ]]"
- }
- )
- class AddFuncCommand(sublime_plugin.TextCommand):
- def run(self, edit):
- self.view.run_command("insert_snippet",
- {
- "contents": "--[[--""\n"
- " * @Description: ${1:desc} ""\n"
- " * @param: ${2:string} ${3:name} ""\n"
- " * @return: ${4:nil}" "\n"
- " ]]"
- }
- )
按键映射
- [
- {
- "command": "add_current_time",
- "keys": [
- "alt+shift+j"
- ]
- },
- {
- "command": "add_func",
- "keys": [
- "alt+shift+k"
- ]
- }
- ]
import datetime
import sublime_plugin
class AddCurrentTimeCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("insert_snippet",
{
"contents": "/**""\n"
" * @Description: ""\n"
" * @Author: ""\n"
" * @DateTime: ""%s" %datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") +"\n"
" */"
}
)
class AddFuncCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("insert_snippet",
{
"contents": "/**""\n"
" * @Description: ""\n"
" * @table: ""\n"
" * @param: ""\n"
" * @param: ""\n"
" * @return: ""\n"
" * @DateTime: ""%s" %datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") +"\n"
" */"
}
)