Skip to content

Instantly share code, notes, and snippets.

@HxriM
Forked from tpitale/README.md
Created January 4, 2021 18:41
Show Gist options
  • Select an option

  • Save HxriM/21ec8a5de7dc3b96a6a2ea61e534841f to your computer and use it in GitHub Desktop.

Select an option

Save HxriM/21ec8a5de7dc3b96a6a2ea61e534841f to your computer and use it in GitHub Desktop.
Sublime Text plugin to create a simple timestamp
  1. Go to Tools > New Plugin
  2. Paste timestamp.py contents and save in User as timestamp.py
  3. Open Preferences > Key Bindings - User (or Default, your call)
  4. Paste keybindings.json, or add a line to your keybindings
  5. Customize the keyboard shortcut to your liking and save
[
{ "keys": ["ctrl+shift+n"], "command": "timestamp" }
]
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment