- import datetime
- import sublime_plugin
- class AddCurrentTimeCommand(sublime_plugin.TextCommand):
- def run(self, edit):
- self.view.run_command("insert_snippet",
- {
- "contents": "--[[--"" "
- " * @Description: ${1:Description}"" "
- " * @Author: JuhnXu"" "
- " * @DateTime: " "%s" %datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") +" "
- " ]]"
- }
- )
- class AddFuncCommand(sublime_plugin.TextCommand):
- def run(self, edit):
- self.view.run_command("insert_snippet",
- {
- "contents": "--[[--"" "
- " * @Description: ${1:desc} "" "
- " * @param: ${2:string} ${3:name} "" "
- " * @return: ${4:nil}" " "
- " ]]"
- }
- )
按键映射
- [
- {
- "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": "/**""
"
" * @Description: ""
"
" * @Author: ""
"
" * @DateTime: ""%s" %datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") +"
"
" */"
}
)
class AddFuncCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("insert_snippet",
{
"contents": "/**""
"
" * @Description: ""
"
" * @table: ""
"
" * @param: ""
"
" * @param: ""
"
" * @return: ""
"
" * @DateTime: ""%s" %datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") +"
"
" */"
}
)