Sublime Forum

Is regex keybindings possible?

#1

In the ST1 documentation, it’s stated that regexes may be used when creating keybindings: http://www.sublimetext.com/docs/key-bindings

I’d like a “select n lines”, where ‘n’ is the number of lines to select. Is that possible to do that in ST2?

Based on the code from the documentation (first line), I tried to translate it to JSON, but I’m getting errors when I’m trying save (neither lines work):

// <binding key="alt+d,/[0-9]+/,w" command="times $1 deleteWord right"/>
{ "keys": "super+alt+l", "/\d\+/"], "command": "times $1 expand_selection", "args": {"to": "line"} },
{ "keys": "super+alt+l", "/\d+/"], "command": "times $1 expand_selection", "args": {"to": "line"} }
0 Likes

#2

I believe this functionality was removed in ST2/3.

0 Likes

#3

Too bad – suppose it have to be wrapped in a plugin?

Is it possible to make the plugin “listen” for how many times the action should b executed, in the sane way described in the old documentation?

0 Likes

#4

I would look at Vintageous - it does this somehow (in reverse, though - so ‘3j’ will move down three lines).

0 Likes