Sublime Forum

Passing keybinding as parameter & rx-based kb definition

#1

Well, I’ve switched to Sublime, I couldn’t help it–it’s a great fun to work with it.

Now, one question/idea:

I suppose this can’t be done:

[code]

the key binding would be triggered by any valid key combination: x, 1x, 10x, 123x, etc.

thisKeyBinding captures the actual sequence pressed by the user

[/code]

This would allow, for example, to add counts to commands easily.

Maybe there’s a better way of achieving the same thing?

0 Likes

#2

Try this:

<binding key="/([0-9]+)/,w" command="times $1 'move words 1'"/>

Submatches in the regex are exposed as $1, $2, $3 etc to the command - a string replace is done on the command before evaluating it.

The ‘times’ command repeats the command given to it (its second arg) by the number of times given to it in its first arg.

0 Likes

#3

Awesome, this is.

Thanks!

0 Likes