Sublime Forum

How to track down a strange keymap conflict

#1

Suddenly when I press CMD+E on a selected work and then CMD+G, expecting to go to the next matching word based on selection, I get this:

I have no idea which plugin is causing this and why is it allowed to just override a well defined native shortcut?

I tried FindKeyConflicts plugin but still cannot detect what is going on, in All Key Mappings buffer report, I only see:

[super+g]
   find_next                                Default               

Please help

0 Likes

#2

You can try following these steps:

  1. Open the Sublime console with View > Show Console from the menu
  2. Enter the command sublime.log_commands(True) and press Enter
  3. Perform the sequence of commands you outlined above
  4. Check the console to see what command it executed when you pressed Cmd+G

When you’re done, you can restart Sublime or repeat these steps replacing True with False to turn off command logging.

That key is bound to the find_next command by default, but whatever it shows will give you a clue about what package you have installed that might be doing it.

The key bindings set in your User package always trump all other bindings elsewhere, so in a pinch you can copy the default binding for this key to your user key bindings to get the default behaviour back regardless.

Out of curiosity, what version of Sublime are you running? Your error message is showing the older icon.

2 Likes

#3

If this happens when you press “CMD+E, CMD+G”, make a search for this keybinding with FindKeyConflicts, not only for CMD+G.

0 Likes

#4

Thank you, here:

Log wasn’t useful, it told me nothing new, just “Formatting failed!” once again, in plain text instead of window:

>>> sublime.log_commands(True)
command: drag_select {"event": {"button": 1, "x": 519.34375, "y": 467.0625}}
command: drag_select {"event": {"button": 1, "x": 526.63671875, "y": 320.02734375}}
command: drag_select {"by": "words", "event": {"button": 1, "x": 526.63671875, "y": 320.02734375}}
command: mix_format_file
error: Formatting failed!
command: drag_select {"eve ....

I then tried to copy { "keys": ["super+g"], "command": "find_next" } to User Key Bindings

But it didn’t help, I still get “Formatting failed” mysterious msg.

I’m using Build 3126.

1 Like

#5

Do you happen to have this installed:

It contains a key binding on super+e that runs the command you’re seeing here. From the looks of things it’s this key that had the conflict, not the one you copied the binding for.

1 Like

#6

Indeed… I had Elixir and ElixirSublime packages… disabled both for now, as I’m not using Elixir actually at the moment.

How did you do this forensics exactly?

Thank you so much

1 Like

#7

I did it myself retrogradely by your tip about super+e and now I see in FindKeyConflicts report:

 [super+e]
   slurp_find_string                        Default               
   mix_format_file                          Elixir  

I really want to know how to prevent this in the future if I want to continue experimenting with packages… because any one of them can screw up something I will try to use months down the road that is built in and overwritten.

But again: how did you find out it was Elixir package?

1 Like

#8

The console output that you posted above shows the following commands being executed:

  • drag_select (three times)
  • mix_format_file
  • drag_select again

The drag_select command is used when you interact with the buffer via the mouse, so those are not of any consequence. However, the command mix_format_file is suspicious.

By default Cmd+E is bound to the command slurp_find_string and Cmd+G is bound to find_next.

Since no slurp_find_string command appears, it’s probably the first of those bindings that’s being hijacked; if it was Cmd+G you would see slurp_find_string being executed, followed by mix_format_file.

In this particular case I Googled mix_format_file and found the Sublime package I linked above, and looking in the default key bindings showed that Cmd+E is bound to the command that you’re seeing here. That doesn’t always work out, but knowing what the command is generally helps you track down what package is causing the problem.

In general you can’t really prevent it except to not try packages, or be aware when they’re adding key bindings.

The rules for key bindings (and many other configurable items) is that all packages can define them and they get combined in a certain order; the Default package (which ships with Sublime) provides the defaults, then all packages are loaded in lexical order and combine with the defaults, and then your User package (where your custom configuration is stored) is loaded last (more info on that can be found here).

In general a well behaved package would either:

  • Provide no default mappings, but show you what to do to make them yourself
  • Provide custom mappings that don’t conflict with anything that has a default
  • Only replace a default binding with another one that includes a context that makes it take effect only where it’s needed

That said there are no requirements in this regard enforced, although these days packages that get added to Package Control will generally be strongly encouraged to follow these guidelines.

2 Likes

#9

All clear now, thank you again, I learned a lot!!

And I’m again at peace having a working editor.

1 Like