Easily build a great vocabulary without studying! Now on the App Store!
Click here for more info about the app

How to Create a Date Time Snippet in Sublime Text 2 (Dynamic Signature with Time Stamp)


You'll have to create a new plugin. From the menu bar select

Tools > New Plugin

Copy the Python script from the signature.py file. Remember to replace your email address (it's example.com). Save the file, signature.py, is fine. Next open up Preferences > Key Bindings - Default and add a new entry.

ctl+alt+s will add the snippet to the first line of your file.

# In Preferences > Key Bindings - Default 
# Add a new entry
{"keys": ["ctrl+alt+s"], "command": "signature" },

Tools > New Plugin

# Save as signature.py
import datetime, getpass
import sublime, sublime_plugin
class SignatureCommand(sublime_plugin.TextCommand):
        def run(self, edit):
                signature = "[%s %s <%s@example.com>]\n\n\t" % (datetime.datetime.now().strftime("%Y-%m-%d %H:%M"), getpass.getuser(), getpass.getuser().lower())

                self.view.insert(edit, 0, signature)
Tagged w/ #date time sublime snippet #signature #snippets #sublime text 2 #text editorsenvironment