When setting up key bindings, I can never get the “following_text” context key to work. As a simple example, I want to replace “&” with “&
” in HTML files, when it’s followed by a space. I can replace the ampersand easily enough. But when I try to make it dependent on the following space, it doesn’t work. I’m sure I’m missing something simple, since I’ve never gotten this to work–with this example, or any number of others. This is just the simplest example I’ve tried.
So this works for just the ampersand:
{ "keys": ["&"],
"command": "insert_snippet",
"args": {"contents":"&"},
"context":
[
{ "key": "selector", "operator": "equal", "operand": "text.html", "match_all": true }
]
}
But when I try this, it just never matches at all–leaves it a bare ampersand:
{ "keys": ["&"],
"command": "insert_snippet",
"args": {"contents":"&"},
"context":
[
{ "key": "selector", "operator": "equal", "operand": "text.html", "match_all": true },
{ "key": "following_text", "operator": "regex_match", "operand": "^ ", "match_all": true }
]
}
(And yes, I know I could accomplish this specific replacement by just using ["&", " "]
for the binding keys. But I’m just using this for a simple test. Ultimately what I want is to check the following_text for, say, “\s
”.)
Can anyone see what I’m doing wrong and tell me? Thanks.