Sublime Forum

Custom Keybindings and Preferences Default vs User

#1

Excited by your Sublime Merge release. Congratulations.

There’s been a couple of things I ran into that I’ve not figured out.

  1. I’m unable to find the edit Key Bind preference so I can remap some
    of the hotkeys to something a bit more intuitive (to me).

  2. When I open preferences > edit settings, it only shows me my user
    settings and not the default. I’m pretty sure the first time I opened
    it it shown both side by side in Sublime Text. But subsequently it has
    not.

Thanks.

2 Likes

Keeping Track of Edits to Default Settings
#2

Yes, a Sublime tool without python feels like something is missing.

The side by side views of preferences / key bindings in ST are implemented as python plugin. As the python plugin API is not yet available I guess we need to be patient.

The Preferences command is a try to create an alternative to edit settings manually, but it is still quite limited and doesn’t include key bindings.

I personally hope we can teach ST’s PackageDev to provide tooltips and completions for settings and all the built-in functions to support editing preferenses and key bindings.

0 Likes

#3

@deathaxe Ah, I was unaware of this. Hopefully that’s released soon.

On the homepage for Sublime Merge it tauts these like they are already available - under the Extensibility section - which had me thinking I was missing something.

0 Likes

#4

You already can customize key bindings, command palette, main menu and all the context menus (branch/commit/…) - everything which does not require python. Just missing some little helpers which make customization of resource files easier.

0 Likes

#5

@deathaxe oh, could you let me know how? That’s one of the problems I’m having.

You say the command pallet doesn’t do Key Bindings. Are you just manually creating a *.json and sticking it somewhere in the sublime config files?

Also, thinking ahead, how do you figure out the command names when settings the key bindings?

Thanks

0 Likes

#6

Merge and Text both share a common code base, so for things like this, anything you can do in Text you can also do in Merge, with the caveat that (at least currently) Text makes this a lot easier by providing an interface to do so while Merge requires you to take the steps manually.

So, creating a sublime-keymap file with an appropriate name in your Merge User package (like Text you can use Preferences > Browse Packages to find it) is enough to make Merge use it.

As an example, I have a Default (Linux).sublime-keymap file (and one for Windows and OSX) with the following contents in it so that I can switch repositories with the same key binding that I’m used to in Text:

[
    // Mimic quick switch project in Sublime.
    { "keys": ["ctrl+alt+p"], "command": "quick_switch_repository" },
]

Similarly you can also create a sublime-commands file to add items to the command palette, such as this example Default.sublime-commands file that adds the previous command to the palette:

[
    { "caption": "Quick Switch Repository", "command": "quick_switch_repository" },
]

As you mentioned in your post, the missing part here is knowing what the command names are, which is the trickier bit and is the part that Text helps you out with by automatically opening the defaults for you.

Merge can’t do that, so it’s up to you to do it yourself.

If you look in the folder that Merge is installed in, you’ll find a folder named Packages, which contain the packages that ship with Merge. The Default - Merge.sublime-package file contains the base key bindings and preferences while Default.sublime-package contains other resources like the menus, command palette entries and so on.

If you copy those package files to somewhere safe and rename them to zip files, you can extract them to see what’s inside them, which is where you can gain insight into the available commands and how they work.

Note that both packages contain key bindings and preferences, but the ones in Default - Merge are the ones that Merge uses; the others are from Sublime. I would imagine that Merge is loading the Default package and then applying the changes from Default - Merge on top.

6 Likes

Customizing key bindings of SublimeMerge
#7

@OdatNurd Amazing, thank you for taking the time writing all that out. Exactly what I was after.

Thanks again.

1 Like

#8

The only file I see under Packages/ is Packages/User/Preferences.sublime-settings. There’s nothing else… is there a way to recover the keybindings file?

0 Likes

#9

If you mean that you want to see what the current key bindings in Sublime Merge are for reference purposes or to rebind them, my post above explains where the Default - Merge.sublime-package is and how to look inside of it to find the default bindings.

0 Likes