Home Download Buy Blog Forum Support

Passing keybinding as parameter & rx-based kb definition

Passing keybinding as parameter & rx-based kb definition

Postby guillermooo on Mon Sep 28, 2009 8:17 pm

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: Select all
<binding key="`[0-9]*`x" command="myCommandAcceptingArgs thisKeyBinding">
# 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


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

Maybe there's a better way of achieving the same thing?
guillermooo
 
Posts: 727
Joined: Thu Jul 23, 2009 9:06 am

Re: Passing keybinding as parameter & rx-based kb definition

Postby jps on Mon Sep 28, 2009 9:08 pm

Try this:

Code: Select all
<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.
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: Passing keybinding as parameter & rx-based kb definition

Postby guillermooo on Mon Sep 28, 2009 9:20 pm

Awesome, this is.

Thanks!
guillermooo
 
Posts: 727
Joined: Thu Jul 23, 2009 9:06 am


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 5 guests