Sublime
1
Datetime plugin
In sublime, I need to print current date and time with a custom shortcut key.
To set up a custom shortcut key in Sublime Text to print the current date and time, you'll need to create a new command and then bind that command to a key combination. Here's a step-by-step guide:
Create a new plugin:
Open Sublime Text.
Go to
Tools
>Developer
>New Plugin...
.Replace the default content with the following script:
Save this file in the
Packages/User
directory (Sublime Text will suggest the correct directory) with a name likeinsert_datetime.py
.
Add a key binding:
Go to
Preferences
>Key Bindings
.In the right-hand user key bindings file, add a new key binding for the custom command. For example:
Make sure to place this entry within the array brackets.
Test the new shortcut:
Open a new file or an existing one.
Press the key combination you set (e.g.,
Ctrl+Shift+Q
).The current date and time should be inserted at the cursor position.
With these steps, you will have created a custom command in Sublime Text that inserts the current date and time when you press your chosen key combination.
Last updated
Was this helpful?