Since I’m too lazy to see if there’s a proper way of doing this…
Use
"""
Based off of https://forum.sublimetext.com/t/run-multiple-commands-command/6848/1,
and I see no license there so AFAIK you need to ask there any time you
even think about doing anything to this source. Or you can just duck
and hope, like I have.
My changes are hereby released completely and irrevocably into the
Public Domain. THE ORIGINAL CODE MAY NOT BE PUBLIC DOMAIN AND THUS
THIS CODE SHOULD NOT BE THOUGHT OF AS PUBLIC DOMAIN.
- Joshua Landau <joshua@landau.ws>
"""
import sublime, sublime_plugin
class RunMultipleCommandsCommand(sublime_plugin.TextCommand):
"""
"args" for this takes _either_ "command" or "commands", where
"commands" is a list of what "command" takes. "args" also takes
an optional "times" parameter, and just runs itself that many
times.
"command" takes either a string (such as "store_selections") or
a dictionary with a "command" attribute, an optional "args"
attribute and an optional "context" attribute.
In the above, the "command" and "args" attribute are as expected,
and the "context" attribute is one of "window", "app" and "text".
"""
def run(self, edit, commands=None, command=None, times=1):
if commands is None:
commands = [command] if command is not None else ]
for _ in range(times):
for command in commands:
self.exec_command(command)
def exec_command(self, command):
# Shortcut for simple command described by one string
if not "command" in command:
if isinstance(command, str):
command = {"command": command}
else:
raise ValueError("No command name provided.")
args = command.get("args")
contexts = {"window": self.view.window(), "app": sublime, "text": self.view}
context = contexts[command.get("context", "text")]
context.run_command(command"command"], args)
This has unfortunate characteristics if you “run out” of autocompletes (the cursor just keeps moving when in the real buffer) but I’m not going to solve that right now…
I think I know what’s happened - you haven’t installed the plugin I said to.
If you do “Tools > New Plugin…” and replace the text with the below and then save to the default place with a good name, it should work.
"""
Based off of https://forum.sublimetext.com/t/run-multiple-commands-command/6848/1,
and I see no license there so AFAIK you need to ask there any time you
even think about doing anything to this source. Or you can just duck
and hope, like I have.
My changes are hereby released completely and irrevocably into the
Public Domain. THE ORIGINAL CODE MAY NOT BE PUBLIC DOMAIN AND THUS
THIS CODE SHOULD NOT BE THOUGHT OF AS PUBLIC DOMAIN.
- Joshua Landau <joshua@landau.ws>
"""
import sublime, sublime_plugin
class RunMultipleCommandsCommand(sublime_plugin.TextCommand):
"""
"args" for this takes _either_ "command" or "commands", where
"commands" is a list of what "command" takes. "args" also takes
an optional "times" parameter, and just runs itself that many
times.
"command" takes either a string (such as "store_selections") or
a dictionary with a "command" attribute, an optional "args"
attribute and an optional "context" attribute.
In the above, the "command" and "args" attribute are as expected,
and the "context" attribute is one of "window", "app" and "text".
"""
def run(self, edit, commands=None, command=None, times=1):
if commands is None:
commands = [command] if command is not None else ]
for _ in range(times):
for command in commands:
self.exec_command(command)
def exec_command(self, command):
# Shortcut for simple command described by one string
if not "command" in command:
if isinstance(command, str):
command = {"command": command}
else:
raise ValueError("No command name provided.")
args = command.get("args")
contexts = {"window": self.view.window(), "app": sublime, "text": self.view}
context = contexts[command.get("context", "text")]
context.run_command(command"command"], args)
I had… Saved it in the packages\user folder as “ScrollInPopup.py”. Restarted ST3 afterwards and it was loaded successfully but I got nothing apart from that error that I posted.
I’ve just deleted the .py file and tried it again. Different name (“PageDownInPopup.py”). Restart and… it works…
but it doesn’t seem like the overlay receives the move command. I have also tried with a run_macro_file command calling a macro with 8 moves and this doesn’t work either. Strangely simply using the move command once does work.