Created
October 4, 2018 13:44
-
-
Save iamaamir/e398d5afb09debe96c87541008867a2b to your computer and use it in GitHub Desktop.
simple Sublime Text 3 plugin to insert Author with timestamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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