If we write div#container and press TAB sublime3 will return
<code><div id="container"></div></code>
How we make that event happen with ENTER instead of TAB
please skip CODE tag only focus on #CONTAINER
Sublime complete on TAB
Presumably you would just have to duplicate the key binding of whatever package you installed that does this and use enter
in place of tab
. I would check the key bindings for that package; from there you could duplicate it into your User
bindings.
sublime3
It was a built-in feature in Sublime Text 3, and you can adjust the corresponding default keybinding from tab
to enter
(I’ve added a context here to only enable it in HTML):
{ "keys": ["enter"], "command": "insert_best_completion", "args": {"default": "\n", "exact": false},
"context":
[
{ "key": "selector", "operand": "text.html.basic" },
{ "key": "preceding_text", "operator": "not_regex_match", "operand": ".*\\b[0-9]+$", "match_all": true },
]
},
This functionality was removed in Sublime Text 4 and cannot be used anymore.
Sublime has never had core functionality that would generate content in that manner unless it was a snippet that was in place, in which case it should still work if it ever did.
Sublime has never had core functionality that would generate content in that manner
If you don’t believe me, here is the proof; it is the html_completions
plugin from the shipped HTML package (here a link to the st3 branch):
Of course this expansion for HTML tags with class or id attributes is still possible in ST4 (requires two steps now), but the opening post is clearly about the one-step tab completion (insert_best_completion
), which was a core functionality (and that is what I was referring to), and which is now gone in ST4. You can tell it from the opening post:
- the title “[…] complete on TAB”
- the description “If we write div#container and press TAB sublime3 will return […]” accurately describes the former tab completion (
insert_best_completion
) - the request to change it to ENTER; this must refer to the
insert_best_completion
, and not to just commit a completion when the autocompletion popup is already visible, because ENTER is already the default key binding for the latter
There are several issues from unhappy users in the issue tracker about the “tab_completion” setting and removal of the old one-step tab completions, of which this one here might be the most relevant one: https://github.com/sublimehq/sublime_text/issues/4421
Unfortunately there has been no feedback from the developers even after two weeks to confirm this regression, which could either mean that it is ignored, or that it is still under internal discussion (I hope for the latter). To help with the decision to address the issue, I can keep collection links to new forum threads about this, which pop up from time to time, in https://github.com/sublimehq/sublime_text/issues/4421#issuecomment-859686760.