Insert current date in Sublime Text

Open packages directory: Quick menu → Preferences: Browse Packages

Create User/insert_date.py

import datetime
import sublime_plugin


class InsertDateCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        timestamp_str = datetime.datetime.now().strftime("%Y-%m-%d:\n")
        for r in self.view.sel():
            self.view.insert(edit, r.begin(), timestamp_str)

Add new key binding to the keymap file: Quick menu → Preferences: Key Bindings

{
  "keys": ["super+k", "super+t"],
  "command": "insert_date"
}

This example defines Cmd+K, Cmd+T sequence to call the new command.

Demo

Done!



Somewhat related: