- Go to Tools > New Plugin
- Paste timestamp.py contents and save in User as timestamp.py
- Open Preferences > Key Bindings - User (or Default, your call)
- Paste keybindings.json, or add a line to your keybindings
- Customize the keyboard shortcut to your liking and save
Last active
February 4, 2025 22:19
-
-
Save tpitale/11e5a2a152ec67a172f9 to your computer and use it in GitHub Desktop.
Sublime Text plugin to create a simple timestamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ "keys": ["ctrl+shift+n"], "command": "timestamp" } | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import sublime, sublime_plugin | |
class TimestampCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
timestamp = "\n[%s]\t" % (datetime.datetime.now().strftime("%Y-%m-%d %H:%M")) | |
self.view.insert(edit, self.view.sel()[0].begin(), timestamp) |
Hi guys! Love this script and use it all the time. The only gripe I've got is that the active window does not scroll down to the input point.
Place cursor at the bottom of a document, scroll up a few pages, hit the keyboard shortcut, and the window does not scroll down to where the time entry was inserted.
What would I need to do to accomplish this?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what about including milliseconds with
%Y-%m-%d %H:%M:%S.%f
thanks for this!