Sublime Forum

Modify shortcuts for "find_all"

#1

Help me understand how to change the hotkey for “find_all” in the file with hotkey I wrote:

{ “Keys”: [ “alt”], “command”: “find_all”, “args”: { “close_panel”: true},
“Context”: [{ “key”: “panel”, “operand”: “find”}, { “key”: “panel_has_focus”}]
}

But does not work when you press “alt”, only old combination is working “alt + enter” and I need to have hotkey on the left side! anyone has any idea how to fix it? (using Mac)

0 Likes

#2

You can’t bind a key to just Control, Alt, Shift or Super (or in combinations with only each other). There needs to be some other key associated as well; these are modifier keys.

As a good rule of thumb when your key bindings don’t seem to be working, open up the Sublime console with Ctrl+` or View > Show console from the menu and turn on input logging with:

sublime.log_input (True)

Note: This logging will remain in effect until you restart Sublime or run the same command again with False instead to turn the option off.

Now press the key combination that you’re trying to bind. Sublime will print out in the console what key combination it thinks you are pressing. This may be something other than what you are expecting to see (for example if your keyboard layout is different than usual) or it might show you nothing at all.

When it shows you nothing there are generally two reasons. One is you’re pressing only a modifier key or keys, and the other is that the operating system or some other program is intercepting the key combination and handling it before it gets to Sublime.

In your case, it’s the former. If you want the key combination to be something on the left side of the keyboard you will need to choose another non-modifier key from the left side of your keyboard to pair with Alt.

2 Likes

#3

Thanks for the advice but it still does not work.
When I have { “keys”: [“control+1”], “command”: “paste” } at settings it works properly (“paste”-when press “control+1”), but with next lines at setting it not working as should

{ “Keys”: [ “control+1”], “command”: “find_all”, “args”: { “close_panel”: true},
“Context”: [{ “key”: “panel”, “operand”: “find”}, { “key”: “panel_has_focus”}]
}

in logs I see the same “key evt: control+1”

0 Likes

#4

The JSON in the key bindings files is case sensitive; your issue is that you used Keys and Context instead of keys and context.

If you fix the case, your binding should work for you.

0 Likes

#5

This time I did copy from native settings and just changed hotkeys but still not working

0 Likes

#6

Seems to work OK for me. The only other thing I can suggest is that there are three different versions of this binding for use in three different panels, so perhaps you haven’t picked the correct one?

There is the Find... panel (⌘+F), Replace... panel (⌘+Alt+F) and Incremental Find panel (⌘+I).

The animated gif below is using the Find... panel since that’s the one you’re mentioning here.

0 Likes