-->

更新日志/头/时间戳插件崇高的文本?(Changelog / Header / TimeStamp

2019-11-02 06:55发布

我在寻找一个简单的崇高文字2插件,将允许我:

  • 插入(希望自动,但不是必需的)用短模板

% Created: TIMESTAMP

% Modified: TIMESTAMP

然后将取代第一TIMESTAMP一次和第二每次保存文件时。

Answer 1:

以下插件将让你一个时间戳(改了这个问题 ):

import sublime_plugin
from datetime import datetime

class TimeStampCommand(sublime_plugin.TextCommand):

    def run(self, edit):
        # formatting options at http://docs.python.org/2/library/datetime.html#strftime-strptime-behavior
        stamp = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")  # 2013-07-18 14:54:23 UTC
        # to get the local time, change utcnow() to now()
        for r in self.view.sel():
            if r.empty():
                self.view.insert(edit, r.a, stamp)
            else:
                self.view.replace(edit, r, stamp)

将其保存为Packages/User/time_stamp.py并通过加入其绑定到CTRL + ALT

{ "keys": ["ctrl+alt+t"], "command": "time_stamp" }

你的键盘映射( Preferences->Key Bindings - User )。

制作一个插件自动更新时间戳是稍微比较复杂,涉及调用事件侦听器。 我还在调试,所以回来看看更多...



Answer 2:

该FileHeader里的插件ST提供此功能等等。



文章来源: Changelog / Header / TimeStamp Plugin for Sublime Text?