Is it possible to bind a key based on regex?
I need to bind to a macro in case I have a cursor \uv{somewhere_in_here}
. There’s no specific language scope inside
Is it possible to bind a key based on regex?
I need to bind to a macro in case I have a cursor \uv{somewhere_in_here}
. There’s no specific language scope inside
You can use the preceding_text and following_text context operands. You would likely use it in combination with regex_match context operator.
See docs.sublimetext.info/en/latest/ … -a-context for more information on context
Thanks, that works!
Code for future readers:
// tab out of \uv{}
{ "keys": "tab"],
"command": "run_macro_file", "args": {"file": "Packages/User/Macros/moveOutOfBracket.sublime-macro"},
"context":
{ "key": "selector", "operator": "equal", "operand": "text.tex" },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "uv\\{.*", "match_all": true },
{ "key": "following_text", "operator": "regex_match", "operand": ".*\\}", "match_all": true }
]
},
// tab out of \uv{}
{ "keys": "tab"],
"command": "move", "args": {"by": "characters", "forward": true},
"context":
{ "key": "selector", "operator": "equal", "operand": "text.tex" },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "uv\\{.*", "match_all": true },
{ "key": "following_text", "operator": "regex_match", "operand": "\\}", "match_all": true }
]
},