I’m trying to turn ctrl+x
into a general kill anything/close anything/escape anything command. So far I have created these key bindings:
{ "keys": ["ctrl+x"], "command": "hide_panel", "context": { "key": "panel_visible", "operator": "equal", "operand": true } },
{ "keys": ["ctrl+x"], "command": "hide_overlay", "context": [{ "key": "overlay_visible", "operator": "equal", "operand": true }] },
{ "keys": ["ctrl+x"], "command": "hide_popup", "context": [{ "key": "popup_visible", "operator": "equal", "operand": true }] },
{ "keys": ["ctrl+x"], "command": "hide_auto_complete", "context": [{ "key": "auto_complete_visible", "operator": "equal", "operand": true }] },
{ "keys": ["ctrl+x"], "command": "clear_selections", "context": [{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": false }]},
{ "keys": ["ctrl+x"], "command": "single_selection", "context": [{ "key": "num_selections", "operator": "not_equal", "operand": 1 }] },
(For reference, “clear_selections” is not a builtin command, but something I added with help from people here.)
This all works well because “ctrl+x” is captured by the key bindings above in the order shown, e.g., I don’t automatically loose a selection at the same time I close the search panel, etc.
I would like to go further and:
- have ctrl+x to hide the status bar, if not captured by anything of higher precedence, i.e., anything in the list above
- have ctrl+x hide the sidebar, if not captured by anything of higher precedence, including the “hide status bar” functionality just mentioned
- have ctrl+x toggle in and out of distraction-free mode, if not captured anything of higher precedence, including the “hide status bar” and “hide sidebar” functionalities just mentioned
(Basically, ctrl+x hides/closes anything it can, and when nothing is left it to hide it reverts to toggling in and out of distraction-free mode.)
My problem is that while I know how to hide status bar (and sidebar), I don’t know how to hide it only if it is visible, which is key to capturing the ctrl+x command, so that it can propagate to “close sidebar” when the status bar is already hidden, etc.
I looked through the lists of key binding contexts mentioned here but I didn’t see anything mentioning the status bar or the sidebar.
Is there a context for the status bar visibility, or some other device I might use to capture the ctrl+x?
Thanks!
=====
PS: Not that it matters for the purpose of this question, but my final plan for world domination is to have “shift+ctrl+x” reopen the sidebar, status bar in reverse order, should I succeed in this