Sublime Text run a macro with key bindings

748 views Asked by At

How do you define key bindings to run recorded macros in Sublime Text 2? I can record a macro, but how do I run it on demand?

1

There are 1 answers

0
NightOwlPrgmr On BEST ANSWER

Assuming you already know how to create and save a macro I will only show how to define a key binding to run the saved macros.

I couldn't locate an answer on SO and Google, so I decided to post the answer here for anyone else who needs to do such functionality in the future.

This has been tested in Sublime 2, but most likely is the same sytax as in Sublime 3. The file location of the saved macro may be different depending on version and where you decided to save your macro file.

In Sublime 2 the macros default to the Sublime 2\Data\Packages\User\ directory and is where I will reference in my example.

Example:

{ "keys": ["alt+shift+o"], "command": "run_macro_file", "args": {"file": "Packages/User/output.sublime-macro"} }

This binding will execute the macro file specified using the alt+shift+o key combination.