Home Download Buy Blog Forum Support

Key Binding Double Keypress

Key Binding Double Keypress

Postby Grafikart on Sat Sep 03, 2011 12:03 pm

Hi,
I'm playing a bit with keybinding and i'm trying to achieve a specific goal
super + d -> select the world under the cursor
and if I press super+d (or just D without releasing super) -> I want to expand the selection to brackets.

I did that
{ "keys": ["super+d","super+d"], "command": "expand_selection", "args": {"to": "scope"} },
{ "keys": ["super+d"], "command": "expand_selection", "args": {"to": "word"}},
But it didn't work :(

Did I miss something ?

Thanks !
Grafikart
 
Posts: 6
Joined: Sat Sep 03, 2011 11:59 am

Re: Key Binding Double Keypress

Postby iamntz on Sat Sep 03, 2011 12:05 pm

I guess this is somehow related to this (see first bug)
iamntz
 
Posts: 897
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Key Binding Double Keypress

Postby jps on Sat Sep 03, 2011 12:10 pm

It's a different issue to the one iamntz is pointing to.

Key bindings are evaluated in a greedy fashion: the first key binding to match the given input will be evaluated. In this case, it's not possible for the ["super+d", "super+d"] key binding to ever be run, as the single ["super+d"] binding will run as soon as super+d is pressed.
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: Key Binding Double Keypress

Postby Grafikart on Sat Sep 03, 2011 12:27 pm

Ok is there a way using context to tell "if text is already selected" then select between bracket" ?
Grafikart
 
Posts: 6
Joined: Sat Sep 03, 2011 11:59 am

Re: Key Binding Double Keypress

Postby jps on Sat Sep 03, 2011 12:30 pm

Yep, the default super+d (ctrl+d on linux and windows) binding does just that, infact:

Code: Select all
   { "keys": ["super+d"], "command": "expand_selection", "args": {"to": "word"} },
   { "keys": ["super+d"], "command": "find_under_expand", "context":
      [
         { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
      ]
   }
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: Key Binding Double Keypress

Postby Grafikart on Sat Sep 03, 2011 1:18 pm

Thanks it works doing :
Code: Select all
   { "keys": ["super+d"], "command": "expand_selection", "args": {"to": "word"} },
   { "keys": ["super+d"], "command": "expand_selection", "args": {"to": "scope"},  "context":
      [
         { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
      ]
   }


But I don't the argument "match_all".
I can't find a doc with all command and all context for ST2 :(
Grafikart
 
Posts: 6
Joined: Sat Sep 03, 2011 11:59 am


Return to Technical Support

Who is online

Users browsing this forum: memomo and 24 guests