Hello everyone,
I am new to SublimeText as well as Python programming so forgive me if I am missing something that should be obvious. I am trying to write a plugin for Sublime Text 1 that inserts a timestamp using this as a reference.
My point of confusion is, how do I bind my newly-created plugin to a key command. The samply plugin runs using <binding key="ctrl+alt+t" command="sample"/>
However the word “sample” is not included in the filename nor within the code. Simularly, in the link I’m trying to emulate, “insert_timestamp” is not referenced anywhere in the code.
If my code looks like this:
[code]import datetime
import sublimeplugin
class InsertTimestampCommand(sublimeplugin.TextCommand):
def run(self, edit):
#grab the active view
view = sublime.activeWindow().activeView()
#generate the timestamp
timestamp_str = datetime.datetime.now().isoformat(' ')
#for region in the selection
#(i.e. if you have multiple regions selected,
# insert the timestamp in all of them)
for r in view.sel():
#put in the timestamp
#(if text is selected, it'll be
# replaced in an intuitive fashion)
view.erase(edit, r)
view.insert(edit, r.begin(), timestamp_str)[/code]
Then what would my key binding look like and how do I know this information?
Thank you very much and I look forward to learning a lot from all of you.
Javier