Sublime Forum

Arrow keys to move cursor forward through code snippets

#1

ode snippets from the auto completion are amazing. I often build my own custom PHP code completions for big blocks of common used code with multiple variable placeholders.

Right now as far as I know, to advance from 1 placeholder to the next I must hit the TAB keyboard key. I am just curious if there is a way to add an alternate method for example hitting the keys CTRL + Right Arrow Key to advance to the next placeholder in a code snippet.

Is this possible? If not, it’s not a big deal but if it is something simple I would love to know or add it. Thanks

0 Likes

#2

The default key bindings define the tab key like this:

{ "keys": ["tab"], "command": "next_field", "context":
    [
        { "key": "has_next_field", "operator": "equal", "operand": true }
    ]
},

In your Keybindings — User file you could create a similar binding for whatever you’d like, e.g.:

{ "keys": ["ctrl+right"], "command": "next_field", "context":
    [
        { "key": "has_next_field", "operator": "equal", "operand": true }
    ]
},
{ "keys": ["ctrl+left"], "command": "prev_field", "context":
    [
        { "key": "has_prev_field", "operator": "equal", "operand": true }
    ]
},
1 Like

#3

Awesome thanks I wasn’t aware of the next_field property so thats great!

0 Likes