Sublime Text添加插入带当前时间说明以及方法

方法
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"
        ]
    }


]

4. 参考:

http://blog.csdn.net/billfeller/article/details/41460345

你可能感兴趣的:(sublime)