Hello,
where can I find built-in Sublime Text 3 command like ‘expand_selection’? I searched both user Packages (located in ~/.config in my case, Linux user) and root Packages (located in /opt) folders, but couldn’t succeed.
Built-in commands customization
Only a handful of commands (e.g. toggle_command, fold, unfold, duplicate_line, wrap_lines) are implemented in Python and those can be found in the Default package. Other commands (such as show_panel, insert, insert_snippet, undo …) are implemented internally.
So, what I’m trying to accomplish is to set proper syntax for the command to be used in. I need to-tag ‘expand_selection’ to work not only in raw HTML but in Handlebars scope as well. So far I’ve tried to set it up like this:
{
"keys": "ctrl+shift+l"],
"command": "expand_selection",
"context":
{ "key": "selector", "operator": "equal", "operand": "(text.html, text.html.handlebars)", "match_all": true }
],
"args": {"to": "tag"}
}
but haven’t succeed. Is there any way to change scope of a internal command?
Use this:
{ "key": "selector", "operator": "equals", "operand": "text.html, text.html.handlebars", "match_all": true }
Works for me (even though I tested with “source.ruby, source.python”).
There are no parenthesis allowed in scope selectors.
[quote=“FichteFoll”]Use this:
{ "key": "selector", "operator": "equals", "operand": "text.html, text.html.handlebars", "match_all": true }
Works for me (even though I tested with “source.ruby, source.python”).
There are no parenthesis allowed in scope selectors.[/quote]
Your example causes following error (as seen in console):
Unable to parse binding {args: {to: tag}, command: expand_selection, context: {key: selector, match_all: true, operand: text.html, text.html.handlebars, operator: equals}], keys: [ctrl+shift+l]}
I believe this is because proper ‘operator’ value is equal, not equals.
Nevertheless, the following still doesn’t work:
{ "key": "selector", "operator": "equals", "operand": "text.html, text.html.handlebars", "match_all": true }
It shows ‘0 selection regions’ when used in Handlebars scope (scope name is ‘text.html.handlebars’).
Yes, the correct operator is equal.
Here is my complete test binding that definitely works, this time properly copy-pasted and not modified on the fly:
{"keys": "ctrl+shift+l"], "command": "expand_selection", "args": {"to": "word"}, "context":
{ "key": "selector", "operator": "equal", "operand": "source.ruby, source.python", "match_all": true }
] },
However, it may be that the {to: tag} argument doesn’t work with the handlebars syntax since I don’t know how exactly it works and how the handlebars syntax defines tags.
Handlebars syntax is HTML-like, so <div>Lorem ipsum</div> would be correct in both raw HTML and Handlebars template. However, the command doesn’t work with the latter.