Key Bindings says that “following_text” is the text after the selection.
However, if there is a selection of length > 0, it matches the text following the left side of the selection (not even following the cursor because it doesn’t matter if the cursor is on the left or right side of the selection).
It can be tested with the following keybinding which matches on following_text regex_contains ^A
{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`${0:$SELECTION}`"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^A", "match_all": true }
]
},
Legend: [..] selection, |: Cursor
123 A[some|] -> No match
123 A[some|]A -> No match
123 A[|some]A -> No match
123 [Asome|] -> Match
123 [|Asome] -> Match
All preexisting keybindings using following_text are always also using selection_empty == true, so they are not affected by this behavior.
I would prefer to have it working as documented, but since that would probably be a breaking change, maybe it can be documented or a new context option could be added that behaves as documented.
Version: Sublime Text 4200 on Windows.