Sublime Forum

Create keyboard shortcuts

#1

I am using an IBM keyboard with my Mac. I hate having to use two key commands to get to the SFTP menu where I am browsing my server. Control Command R, then Control Command B.

I looked at creating my own keybindings, but even that seemed a little beyond me. Has anyone done this before that can lend me a hand?

0 Likes

#2

Not sure what the SFTP menu is, however to create a keybinding select (from top menu)
Preferences->Keybinding

You should get a window up that has the defaults on the left handside and user keybindings on the right.

In the user section paste something like:

{ "keys": ["ctrl+r",ctrl+b], "command": *THIS IS THE BIT I DON'T KNOW*},

into it and save.
Obvs don’t paste that above command in because I don’t know what the SFTP menu is and the appropriate command. So this is a bit of an intro if you like to the process.
There is possibly another issue in that your new command will conflict with crtl+r (You’ll have to press it twice from now on) so hopefully greater/more experienced minds will take over from me at this point.

I’ve saved a key binding (in my user keybinding menu) which allows me to bring up the keybinding section (saving a few keystrokes) (someone else came up with it)

	{
	"keys": ["ctrl+alt+shift+k"],
	"command": "edit_settings",
	"args": {
		"base_file": "${packages}/Default/Default ($platform).sublime-keymap",
		"default": "[\n\t$0\n]\n"
	}
},

Press control+alt+shift+k to get the keybinding menu up. Also your last keybinding doesn’t need the comma at the end of the final curly bracket. If I remember correctly (I don’t think I’ve installed a plugin that does this) the user keybinding tab/window shows you if you’re making a syntax mistake, and won’t let you save if you have. Once you’ve pasted/typed your keybinding and saved you can close the window, it should be activated immediately.

Hopefully that might get you started and hopefully someone can help you out with the stuff I don’t know! (the most important bit, sorry)

:unicorn::skull_and_crossbones:

0 Likes

#3

Generally speaking, you want to choose Preferences > Package Settings > SFTP > Key Bindings from the menu. This will open up a window with a split in it; the left part is the default key bindings applied by the package, and on the right is your user specific key bindings (or, if you haven’t created any yet, this will be a new empty file).

What you do is find the binding you want to modify in the left, copy it to the pane on the right, and then change the key as appropriate.

For example, on Linux, the binding in the left is like so:

	{ "keys": ["ctrl+alt+r","ctrl+alt+b"], "command": "sftp_browse_server" },

So, you’d copy that over to the right hand pane and change the keys part to be only a single key. Note however that keys must always be a list, though it can be a list with just one thing in it:

	{ "keys": ["ctrl+alt+shift+b"], "command": "sftp_browse_server" },

Key binding files are JSON and have a specific format; look to the left hand side of the window for examples of this, but in general make sure that the file starts with [, ends with ] and that all bindings are separated by commas.

Sublime’s JSON format is lenient; it allows comments and for trailing comments on the final item (if you’re familiar with JSON that may catch you unaware).

More information in general can be found in the official documentation on key bindings and in the following videos.

0 Likes

#4

I’ve tried this, it’s the whole file, on the right, and doesn’t work sadly.

0 Likes

#5

The names of keys you can use in bindings are case-sensitive; try using f11 instead of F11.

0 Likes

#6

Thank you so much

1 Like