hotkeyssublimetext4

How to debug Sublime Text .sublime-keymap files


I'm trying to make some hotkey modification in sublime but can't seem to get them to take. I'm using an M1 Mac running 13.3.1. The goal is to remap Command+shift+up/down to shiftings lines up/down, and then to switch the hotkeys for find and replace.

These are the changes to /Applications/Sublime Text.app/Contents/MacOS/Packages/User/Default.sublime-keymap:

[
    {
        "keys": ["super+shift+up"],
        "command": "swapLines",
        "args":
        {
            "direction": "up"
        }
    },
    {
        "keys": ["super+shift+down"],
        "command": "swapLines",
        "args":
        {
            "direction": "down"
        }
    },
    {
        "keys": ["super+f"],
        "command": "showPanel",
        "args":
        {
            "panel": "replace"
        }
    },
    {
        "keys": ["super+alt+f"],
        "command": "showPanel",
        "args":
        {
            "panel": "find"
        }
    }
]

I don't get any errors when opening up sublime with these changes, but none of the behavior changes when I try to test it out.


Solution

  • commands in Sublime Text 4 are camel_case - that is why nothing happens when you press your key combinations. Sublime may report missing commands in the Console when you press those triggers.

    One way to tell what command you need is to look at the existing keybindings - which refer to swap_line_up and swap_line_down for example. Or to turn on command logging (sublime.log_commands(True)Enter) in the console (View menu -> Show Console) and then run an action from the menu or an existing keybinding and see what is logged.