SQLTerminal.app
now available

XPath.app
now available
Want fresh tech tips in your inbox?

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

Apps I've Built

XPath Expression Editor
Practice and improve your XPath skills with XPath Editor
Click to buy on the App Store
Photo Location Changer
Easily change the location on your photos and videos
Click here for more info about the app
Photo Date Changer
Easily change the dates and times on your photos and videos
Click here for more info about the app
VocabReminder
English dictionary with notifications so you won't forget what you're studying!
Click here for more info about the app
VocabQuiz
The app that quizzes and scores you on your vocabulary!
Click here for more info about the app