处理 Sublime Text 3 添加插入当前时间

1.制作插件

    1.1  插件放置地址,工程路径:Preference → Browse Packages 进入 User目录  新建 -> addCurrentTime.py

    1.2addCurrentTime.py 

import datetime
import sublime_plugin
class AddCurrentTimeCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.run_command("insert_snippet",
            {
                "contents": "%s" % datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            }
        )


2.设置调用

    2.1  开发工具路径:Preference → Key Bindings - User 

       [
    {
        "command": "add_current_time",
        "keys": [
            "ctrl+shift+."
        ]
    }
]

3.使用快捷 :ctrl+shift+.

猜你喜欢

转载自blog.csdn.net/jeremyjone/article/details/80517990