To instruct Sublime Text to run macros, you need to pass "run_macro_file" as parameter to "command", with argument being the filename of the macro.
First, merely recording a macro doesn't save it to a file, you'll have to save the macro to a file. This can be done by clicking on Tools → Save Macro & then give a filename. Macros are generally saved in %appdata%\Sublime Text 2\Packages\User
folder.
Next, to assign the keyboard shortcut, open the Keybindings file from Preferences → Key Bindings - User.
Now, the general format for a keybinding is as below:
{ "keys": [<key sequence>], "command": "run_macro_file", "args": {"file": "Packages/User/<file name>.sublime-macro"} }
So, if you want to assign Ctrl+Shift+X to a macro which has been saved as "add comma to end", the keybinding line will look like so:
[
{ "keys": ["ctrl+shift+x"], "command": "run_macro_file", "args": {"file": "Packages/User/add comma to end.sublime-macro"} }
]
2this applies equally to ST3 - thanks! – ptim – 2015-02-14T00:31:47.433