Sublime Forum

How can I change the keybinding to exit Ctrl+p

#1

When I press Ctrl+p to select a file in my project, I would like to be able to press Ctrl+[ to exit the menu instead of having to press Escape.

0 Likes

#2

If you open the Sublime console with View > Show Console, you can enter sublime.log_commands(True) to turn on command logging; with that enabled you can execute commands and check the console to see what’s logged.

Opening Goto Anything and then pressing Esc yields the following logs:

command: show_overlay {"overlay": "goto", "show_files": true}
command: hide_overlay

So, the key binding you want is:

    { "keys": ["ctrl+["], "command": "hide_overlay" },

Optionally, you can augment the key binding as:

	{ "keys": ["ctrl+["], "command": "hide_overlay", "context":
		[
			{ "key": "overlay_visible", "operator": "equal", "operand": true }
		]
	},

This version does the same thing, but makes the key only active if the overlay is actually visible; this mimics what the default key binding for this does. This would allow for the same key to be used in other circumstances, for example.

3 Likes

#3

Thanks! This helped out a lot.

0 Likes