I use ST2/3 as my primary LaTeX editor and push all my git commits onto GitHub. For several reasons, I need to use hard line breaks—"word wrap" doesn't do the trick. I have installed the WrapPlus package via Package Control, and while very helpful, and so far reliable, it needs to be triggered manually using a shortcut.

Is there a way to have this done automatically, e.g. by triggering the WrapPlus command every time I type a whitespace? It seems that sublime_plugin.EventListener does not provide a method for tracking the last character entered into the buffer, so some major (and possible inefficient) intervention might be needed to obtain that information.

(Incidentally, it would be nice to have a "meta-package" of sorts that would parametrically run any command whenever a given event is triggered. Any volunteers? )

You could probably use the "on_modified" event listener to run the command. Though to get it to run after a space was inserted would take a little bit more work. Untested, but something like the following would run the command after every modification. Again, you would have to do some work to see what the last character entered was.

Many thanks, Skuroda, I tried something along the lines of what you described (in your code snippet) and the result was a total mess—garbled text and noticeable latency between text entry and display. I would indeed need to have it run only when whitespace is entered (probably by diff-ing the buffer in the vicinity of the cursor before and after the keystroke, right?). This seems like too much work given my tight schedule unfortunately… But an idea for the future, certainly.