Key bind for arrow keys in sublime

399 Views Asked by At

I use sublime text editor for writing code, and I want to set up a key binding for arrow keys, so I don't need to move my right hand frequently. To do so, I added code in sublime-keymap:

[
{ "keys": ["alt+j"], "command": "move", "args": {"by": "characters", "forward": false} },
    { "keys": ["alt+l"], "command": "move", "args": {"by": "characters", "forward": true} },
    { "keys": ["alt+i"], "command": "move", "args": {"by": "lines", "forward":false} },
    { "keys": ["alt+k"], "command": "move", "args": {"by": "lines", "forward": true} },
]

But, alt+j and alt+k are not working. Please help. I tried to key bind in VS code too, the same problem occurs. I am using OS Windows 10; the hotkeys defined by windows is creating this issue?

1

There are 1 best solutions below

0
On

For vscode only, the commands are a little different (in your keybindings.json):

{
    "key": "alt+j",
    "command": "cursorMove",
    "args": {
        "to": "left",
        "by": "character"
    },
    "when": "editorTextFocus"
},
{
    "key": "alt+l",
    "command": "cursorMove",
    "args": {
        "to": "right",
        "by": "character"
    },
    "when": "editorTextFocus"
},
    {
    "key": "alt+i",
    "command": "cursorMove",
    "args": {
        "to": "up",
        "by": "line"
    },
    "when": "editorTextFocus"
},
    {
    "key": "alt+k",
    "command": "cursorMove",
    "args": {
        "to": "down",
        "by": "line"
    },
    "when": "editorTextFocus"
}

This is for moving the cursor within an editor. If you wanted arrow key-like functionality in a list - like the Explorer files - you would have to add some more keybindings with different commands. But it looks like you just want within a text editor.