Sublime Forum

Suggestions to centralize key bindings (across OSes)

#1

Currently you can either have different files for each OS or “one to rule them all”.

The problem with the first option is that, if you want to target all three OS architectures, you need to do your changes three times (one is slightly different).
The problem with the second option is that OSX bindings are different in that they use super instead of ctrl.

I have the following suggestions to allow for a centralized format:

Example:


	{ "keys": "primary+x"], "command": "cut" },
	{ "keys": "primary+c"], "command": "copy" },
	{ "keys": "primary+v"], "command": "paste" }
]
  1. The “primary” key modifier. Maps to “ctrl” on Windows+Linux and “super” on OSX. It was first mentioned in some ST changelog and the terminology makes sense imo.

  2. The “keys” key in a key bindings entry can also be a mapping that specifies which OS the value (with the key chords) should be active on. This would be nice if it supported to specify two OSes in a key so that you don’t have to duplicate the chords for Windows&Linux.

Example:


	{ "keys": {"osx": "ctrl+c"], "*": "ctrl+break"]}, "command": "exec", "args": {"kill": true} }
]

The name for a key bindings file like this could then be arbitrary or follow the old convention of Default.sublime-keymap. Since this only has additions to the current format it would not be a breaking change either.

0 Likes

#2

This only works for the most basic of keyboard shortcuts, like copy and paste. On OS X I want the Command+c, Command+v to copy, paste etc but I also want Control+e, Control+a etc to move around lines. With your suggestion these would all be mapped to the command key instead. Examples:

Control+e: move to the end of line
Command+e: use selected for find
Control+d: delete forward
Command+d: select word
Control+f: move forward
Command+f: find

…and so on.

0 Likes

#3

I think you misunderstood. The “primary” modifier is just a shorthand for ctrl or super depending on OS and only applicable for situations where you have “super+” on OSX and “ctrl+” on the others. It does not replace ctrl or super.

Suggestion 2 is intended for the more complex cases.

0 Likes