Sublime Forum

Macros - certain commands won't work

#1

Hi,
I’m trying to write a macro, that involves switching groups and finding some text, among others.

I read somewhere, that certain operations won’t be recorded by the Macro Recorder, like switching windows, tabs etc… But I still hope, that these would work if manually added to the macro file.

I’m using this page as a command reference:
https://www.sublimetext.com/docs/1/commands

Below is an example of command that doesn’t work:

{
	"command": "focusGroup",
	"args": {
		"group": 1,
	}
},

or this one:

{
	"command": "findUnder",
	"args": null
},

Could someone confirm if those commands are supposed to work or not? Is there any alternative to automate certain tasks that involve switching between tabs or groups, selecting text in one window and searching for it in another?

0 Likes

#2

Macros can only record and play back TextCommand commands; that is, commands that modify the state of the current file, like changing a setting, editing text or moving the cursor around. The recorder won’t record any other type of command and also won’t play them back.

You can however use Chain of Command or Multicommand to create a key binding that will execute any sequence of commands that you like.

Using either one is pretty straight forward, and the only difference between the two is in how you indicate what commands to execute. I have a video that covers both of them as well.

2 Likes

#3

That documentation is for ST1, which is insanely old. These days, commands are lower_snake_case.

1 Like

#4

Thank you both for your help.

The video was great and the little Packages do the great job - just what I needed!

And good tip regarding the out-of-date commands page.

I had a good fun automating my copy-search-paste job! :slight_smile:

0 Likes