Mario21
Mario21

Reputation: 25

How to turn completions on and off in Sublime Text

Completions are useful but sometimes they get in the way. Is there any way to turn them on and off?

enter image description here

Upvotes: 0

Views: 554

Answers (1)

mattst
mattst

Reputation: 13980

The box in your screen capture shows the Sublime Text completions feature.

To turn completions off set the auto_complete setting to false in your user Preferences.sublime-settings file. The user settings file can be accessed from the menu with Preferences --> Settings, edit the file in the right column of the window that opens. Just add this line:

"auto_complete": false,

There are lots of settings related to the completions feature. Here is a list:

// Enable auto complete to be triggered automatically when typing.
"auto_complete": true,

// The maximum file size where auto complete will be automatically triggered.
"auto_complete_size_limit": 4194304,

// The delay, in ms, before the auto complete window is shown after typing
"auto_complete_delay": 50,

// Controls what scopes auto complete will be triggered in
"auto_complete_selector": "meta.tag - punctuation.definition.tag.begin, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",

// Additional situations to trigger auto complete
"auto_complete_triggers": [ {"selector": "text.html", "characters": "<"} ],

// 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,

// Controls if auto complete is shown when snippet fields are active.
// Only relevant if auto_complete_commit_on_tab is true.
"auto_complete_with_fields": false,

// Controls what happens when pressing the up key while the first item in
// the auto complete window is selected: if false, the window is hidden,
// otherwise the last item in the window is selected. Likewise for the
// down key when the last item is selected.
"auto_complete_cycle": false,

// When enabled, pressing tab will insert the best matching completion.
// When disabled, tab will only trigger snippets or insert a tab.
// Shift+tab can be used to insert an explicit tab when tab_completion is
// enabled.
"tab_completion": true,

You could set up a key binding to toggle the setting on and off like this:

// Change the keys to whatever you want.
{ "keys": ["ctrl+shift+y"], "command": "toggle_setting", "args": {"setting": "auto_complete"} },

Note that the toggle_setting command will not change the value in the Preferences.sublime-settings file just its value in memory.

You could also set syntax specific or project specific settings as to whether to have auto_complete on by default.

Upvotes: 1

Related Questions