Skip to content

Instantly share code, notes, and snippets.

@iamaamir
Created October 4, 2018 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamaamir/e398d5afb09debe96c87541008867a2b to your computer and use it in GitHub Desktop.
Save iamaamir/e398d5afb09debe96c87541008867a2b to your computer and use it in GitHub Desktop.
simple Sublime Text 3 plugin to insert Author with timestamp
import sublime, sublime_plugin
from time import localtime, strftime
class InsertDatetimeCommand(sublime_plugin.TextCommand):
def run(self, edit):
format = "%d/%b/%Y/(%I.%M:%p)"
current_date = strftime(format, localtime())
content = "Author: Aamir khan (aamirkhan180@gmail.com)\n{}\n".format(current_date)
sel = self.view.sel();
for s in sel:
if s.empty():
self.view.insert(edit, s.a, content)
else:
self.view.replace(edit, s, content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment