Sublime Forum

Trying to do a simple custom keybinding

#1

I’m struggling to do something simple.
Basically I just want ctrl-up and ctrl-down to be the same as plain up and and down - it’s a habit I have for fast navgiating around a file.
The docs don’t seem to have a section on exactly what methods are available and how to use them, at least that I could find. So I usually use the existing ones reference. However for something as simple as moving the cursor one line there is no existing binding.

0 Likes

#2

When doing keybindings (or modifying settings in general), be sure to look at the defaults included with Sublime Text. The default Key Bindings will be shown by selecting Preferences -> Key Bindings - Default. Searching for “up” and “down” led me to the following entries.

	{ "keys": "up"], "command": "move", "args": {"by": "lines", "forward": false} },
	{ "keys": "down"], "command": "move", "args": {"by": "lines", "forward": true} }

So, to add your custom binding, add the following to your user key bindings (Preferences -> Key Bindings - User). Be sure to wrap it in square braces (the key bindings file is an array of objects) if you don’t have any entries already.

	{ "keys": "ctrl+up"], "command": "move", "args": {"by": "lines", "forward": false} },
	{ "keys": "ctrl+down"], "command": "move", "args": {"by": "lines", "forward": true} }

Hope that helps.

0 Likes

#3

Thank you - I had tried what you mentioned below and didn’t find the up or down key binding. So confused I guessed that perhaps you were on windows - and indeed the windows keymap has those bindings but my OSX keymap doesn’t…
Anyway I have what I need now - thanks for the help.

0 Likes