Sublime Forum

Could use a little help with command chaining for key bindings


I’m trying to recreate functionality that I really like on PHPStorm that goes like this:

  • When the sidebar is closed, super+b opens and focuses the sidebar
  • When the sidebar is open and focused, that same super+b closes the sidebar and returns the focus to the current page

The following custom bindings work to open and focus the sidebar, but I’m having trouble getting that same binding to close it and return focus to the file once open:

// toggle and focus sidebar
{ "keys": ["super+b"], "command": "chain", "args": {
    "commands": [
    "context": [
    	{"key": "panel_has_focus", "operator": "not_equal"}


You can’t do it with the same key binding; you would need a separate key binding on the same key but with a different context that causes it to only be active while the side bar is focused, which takes the action of switching the focus.

That said, I don’t think there’s a context that does that out of the box and I’m not sure offhand if there’s a way via the API to know that the sidebar has the focus.



I use the plugin created by @FHTheron. When the sidebar is closed, it opens the sidebar, shows the file in the respective folder, and focuses on the sidebar. When the sidebar is open, it closes it and focuses on the file.