Sublime Forum

Regexes confused by multiple key bindings?

#1

This is a sequel of a previous post which was a bit
confused, now I think I can ask a precise question:

The following keybinding works fine:

{
 "keys": "a"],  "command": "insert_snippet",  "args": {"contents": "\\alpha"},
  "context":
  
    { "key": "preceding_text", "operator": "regex_match", "operand": "^$" }
  ]

}
]

When you press ‘a’ at the start of a line (empty or not) it inserts
\alpha, otherwise it inserts ‘a’. I can see no difference if I use
“regex_contains” instead of “regex_match”

But the following binding does not work:

{
 "keys": "a","b"], "command": "insert_snippet", "args": {"contents": "\\alpha"},
  "context":
  
    { "key": "preceding_text", "operator": "regex_match", "operand": "^$" }
  ]

}
]

Here when I press “a” “b” in sequence, nothing happens ever, beginning
of line or not. Same thing with “regex_contains”. If I replace the regex
with “^” , still nothing, and finally the combination regex “^” and
“regex_contains” always matches, anywhere in the line.
I can’t understand what is going on

Piero

0 Likes