Sublime text macro to insert timestamp

platform-edc $ cat ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/
import sublime_plugin
from datetime import datetime
class TimeStampCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        # formatting options at
        stamp ="%Y-%m-%d_%H:%M:%S")  # 2013-07-18 14:54:23
        for r in self.view.sel():
            if r.empty():
                self.view.insert(edit, r.a, stamp)
                self.view.replace(edit, r,   stamp)

platform-edc $

Documentation - see


Add this to Keybindings / User

![](/images/2013-09-23_8.02.19 PM.png)