So, I took my first hack at writing a super simple plugin for Sublime 3.
All I needed were my initial and the current date, as you can tell, I started with the example Hello World plugin and the docs and just modified from there.
heres the code:
import sublime
import sublime_plugin
import datetime
class ExampleCommand(sublime_plugin.TextCommand):
def run(self, edit):
day = (datetime.datetime.now().strftime("%Y-%m-%d"))
sig = "OE " + day
self.view.insert(edit, 0, sig)
I also registered the following key binding:
[
{"keys": ["f5"], "command": "example" },
]
-Now, when I open up a new blank file and press f5, I get:
OE 2017-10-12
which is correct.
But, when I do this in say, index.php on a new line, a file where there is plenty of existing code, the plugin won’t fire, meaning that I hit f5 and NOTHING happens.
The console reports no errors, and I can run the command view.run_command(“example”) and get the proper output in a blank file but not in the php file.
Also, running sublime.log_input(True) to log my inputted keys is returning f5 for my keypress, so I know its not getting misinterpreted.
How can I make this plugin run in all files?