How to disable/override the enter key for autocomplete?
Solution 1
I have never used Sublime Text 3, but I don't think the following has changed since Sublime Text 2.
What you want to achieve is actually a standard feature in Sublime Text. You just have to turn it on.
This line from your the code you quoted …
{ "key": "setting.auto_complete_commit_on_tab", "operand": false }
… means "only execute the command if the setting called 'auto_complete_commit_on_tab' is set to false". So simply turn on that setting.
In Default/Preferences.sublime-settings:
// By default, auto complete will commit the current completion on enter.
// This setting can be used to make it complete on tab instead.
// Completing on tab is generally a superior option, as it removes
// ambiguity between committing the completion and inserting a newline.
"auto_complete_commit_on_tab": false,
Put "auto_complete_commit_on_tab": true
in User/Preferences.sublime-settings. Both mentioned files can be accessed via the Preferences menu.
Solution 2
You can assign it to a non existent command. Try adding the following to User/Default (OSX).sublime-keymap
{ "keys": ["enter"], "command": "noop", "context":
[
{ "key": "auto_complete_visible" },
{ "key": "setting.auto_complete_commit_on_tab", "operand": false }
]
}
Granted if you install/write a plugin that has a command noop
you will need to change this command.
Edit
Lydell's solution is better :) Forgot about that setting (though it is in the context so I should have known...). Guess my answer is a more generic "how to disable a keybinding".
Related videos on Youtube
gak
Updated on June 25, 2022Comments
-
gak about 2 years
In Sublime Text 3, I want to disable the enter key to select an item from the autocomplete drop down, and only allow the tab key to do so.
I found this section in the inbuilt
Default (OSX).sublime-keymap
file:{ "keys": ["enter"], "command": "commit_completion", "context": [ { "key": "auto_complete_visible" }, { "key": "setting.auto_complete_commit_on_tab", "operand": false } ] },
It seems that if I remove this from the config that enter will not select an item in the drop down. Unfortunately it is not recommended to change this file, and only to override it in my
User
files. I don't think I actually can edit it without modifying the.app
contents.I tried to override it by removing different sections, and also remove everything except
"keys": ["enter"]
, but nothing seems to work.How would I go about achieving this without modifying the inbuilt
Default (OSX).sublime-keymap
and only theUser/Default (OSX).sublime-keymap
file? -
cimmanon about 11 yearsI love the description for this setting "it's better if this setting is true, but we're going to set it to false by default"
-
chris over 8 yearsSounds like it is because it takes time to get used to: "Enabling Commit on Tab is recommended, but it will take a short time to get used to." sublimetext.com/docs/2/auto_complete.html
-
frumbert almost 6 years
tab
makes so much more sense thanenter
to me; took about 2 seconds to get used to.