Sublime Forum

Solved: Key bindings to make the escape key prioritize clearing multiple selections over closing an unfocused panel

#1

The escape key has many functions in ST; hides overlays, auto-complete, and popups; closes panels; and clears tabbed fields and multiple selections. The escape key’s order of precedence has been annoying me for some time (a minor quibble I must say) - closing unfocused panels is prioritized over clearing multiple selections. I’m posting this because I finally spent the 10 mins required to work out the fairly complex key binding to change this. I suspect that I am not the only one who finds this small aspect of ST’s behaviour annoying and would also like to change it, after all if you’ve left a panel open (almost always the console in my case) it’s because you want it open.

The escape key binding below does the following: If there are multiple selections in the active buffer and there is a panel visible which is NOT focused, then when the escape key is pressed the multiple selections are cleared instead of the panel being closed. All other aspects of the escape key’s order of precedence remain the same as they were.

{ "keys": ["escape"], "command": "single_selection", "context":
    [
        { "key": "num_selections", "operator": "not_equal", "operand": 1 },
        { "key": "panel_visible", "operator": "equal", "operand": true },
        { "key": "panel_has_focus", "operator": "equal", "operand": false },
        { "key": "overlay_visible", "operator": "equal", "operand": false },
        { "key": "popup_visible", "operator": "equal", "operand": false },
        { "key": "has_next_field", "operator": "equal", "operand": false },
        { "key": "has_prev_field", "operator": "equal", "operand": false },
        { "key": "auto_complete_visible", "operator": "equal", "operand": false }
    ]
},

HTH.

1 Like