Sublime Forum

Multiple commands on one hotkey

#1

Can i trigger 2 commands with 1 hotkey? i want to achieve something like this:

[code] {
“keys”: “left”],
“command”: “set_layout”,
“args”:
{
“cols”: [0.0, 0.666, 1.0],
“rows”: [0.0, 1.0],
“cells”: [0, 0, 1, 1], [1, 0, 2, 1]]
},

	"command": "focus_group",
	"args": { "group": 0 }
},



{
	"keys": "right"],
	"command": "set_layout",
	"args":
	{
		"cols": [0.0, 0.333, 1.0],
		"rows": [0.0, 1.0],
		"cells": [0, 0, 1, 1], [1, 0, 2, 1]]
	},
	"command": "focus_group",
	"args": { "group": 1 }
},[/code]
0 Likes

#2

You could probably write your own command that triggers these two in a sequence.

0 Likes

#3

You can use macros. Like so:

.sublime-keymap:

{ "keys": "left"], "command": "run_macro_file", "args": {"file": "Packages/User/Left Layout.sublime-macro"} },

Packages/User/Left Layout.sublime-macro:


      "command": "set_layout",
      "args":
      {
         "cols": [0.0, 0.666, 1.0],
         "rows": [0.0, 1.0],
         "cells": [0, 0, 1, 1], [1, 0, 2, 1]]
      },

      "command": "focus_group",
      "args": { "group": 0 }
]

(I didn’t test this out, so this may not work out of the box.)

Look in Packages/Default for keymaps that utilize macros as well as the macros themselves.

Hope this helps,
Alex

0 Likes