Date stamp
Sublime Text does not have a built-in option to insert a date stamp, and it needs to be created. From Tools > Developer > New Plugin… within Sublime Text, replace the template with the following python script:
import sublime
import sublime_plugin
from datetime import datetime
class InsertFormattedDateCommand(sublime_plugin.TextCommand):
def run(self, edit):
formatted_date = datetime.now().strftime("%Y-%m-%d %H:%M")
self.view.run_command("insert", {"characters": formatted_date})
Under Sublime Text Package/User folder, save the above script as insert_formatted_date.py
. Add a keyboard shortcut to get the date under Preferences > Key Bindings:
[
{
"keys": ["ctrl+shift+d"],
"command": "insert_formatted_date"
},
]
Save the key bindings file, close Sublime Text, and reopen. Now using CtrlShift d , insert formatted date.
The above is at best comparable to Vim’s much simpler via an abbreviation, like so:
abbr <expr> ds strftime('%Y-%m-%d %H:%M')
Feb 2025: On a thread discussing this, Sublime Text developer shared that a one-liner is possible too — using Arithmetic, a feature that is as yet unfamiliar to me, from the command palette (i.e. CtrlShift p ), where among other things one can just string code like below to produce a date stamp in Sublime Text (similar to Vim).
__import__('datetime').datetime.now().strftime("%Y-%m-%d %H:%M")
While not handy as a keyboard shortcut, I think it can be made into one, i.e., attach the above snippet to a trigger and have Sublime Text produce this code literally on a line. Then select this line, and use Arithmetic from the command palette.