Home Download Buy Blog Forum Support

Trying to do a simple custom keybinding.

Trying to do a simple custom keybinding.

Postby logorman on Mon Jan 07, 2013 10:14 pm

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.
logorman
 
Posts: 2
Joined: Mon Jan 07, 2013 10:05 pm

Re: Trying to do a simple custom keybinding.

Postby skuroda on Mon Jan 07, 2013 10:29 pm

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.

Code: Select all
   { "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.
Code: Select all
   { "keys": ["ctrl+up"], "command": "move", "args": {"by": "lines", "forward": false} },
   { "keys": ["ctrl+down"], "command": "move", "args": {"by": "lines", "forward": true} }


Hope that helps.
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: Trying to do a simple custom keybinding.

Postby logorman on Tue Jan 08, 2013 6:49 am

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.
logorman
 
Posts: 2
Joined: Mon Jan 07, 2013 10:05 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 32 guests