Sublime Forum

[SOLVED] ST3: "tab_completion": false does not work


I have this code: if (var).
After if I need to use TAB.
I try to use TAB and get:

if (/* condition */)
    /* code */

I’ve tried to disable TAB completion via “tab_completion”: false in C.sublime-settings (as well as in Preferences.sublime-settings), but it does not disable TAB completion (even after ST3 was closed-opened). How do I completely disable TAB completion?

UPD. I set “tab_completion”: false also in C++.sublime-settings. No effect.
In total I have “tab_completion”: false in three files:

  1. Preferences.sublime-settings
  2. C++.sublime-settings
  3. C.sublime-settings

Setting tab_completion false does not work

The comment on tab_completion says:

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

The second part of this is what you’re tripping on here; the expansion of if to this condition is a snippet, so turning this off has no effect on what’s actually happening to you.

Specifically, while you’re editing a C file if you use Tools > Snippets from the menu, one of the items that appears in the list is Snippet: If Condition; if you look to the right, the trigger for expanding it out is if, tab. i.e., pressing Tab after the word if expands out the snippet, whose body is defined as:

if (${1:/* condition */})
	${0:/* code */}

If you want Tab to never expand anything including a snippet, you need to add a custom key binding for it to your user defined key bindings.

To do that, choose Preferences > Key Bindings from the menu and add these bindings to the right hand pane:

    // Disable all autocompletion and tab completion. This overrides the default
    // binding for this key, which invokes 'insert_best_completion'.
    { "keys": ["tab"], "command": "insert", "args": {"characters": "\t"}},

    // This is a duplicate of a default binding; it makes sure that pressing tab
    // on a blank line will jump the cursor to the correct indent
    { "keys": ["tab"], "command": "reindent", "context":
            { "key": "setting.auto_indent", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "preceding_text", "operator": "regex_match", "operand": "^$", "match_all": true },
            { "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true }

    // This is a duplicate of a default binding; it ensures that if the
    // selected text contains multiple lines, pressing tab will indent the
    // whole block
    { "keys": ["tab"], "command": "indent", "context":
            { "key": "text", "operator": "regex_contains", "operand": "\n" }

Builds of Sublime Text >= 4050 include a setting that allows you to disable snippets in packages, which would also do this without requiring the key binding (in addition to turning off tab completion as you did above, just to stop other autocomplete mechanisms):

	// A list of wildcard patterns specifying which snippet files to ignore.
	// For example, to ignore all the default C++ snippets, set this to
	// ["C++/*"]
	"ignored_snippets": [],
1 Like


Thanks for the detailed explanation!
I’ve ended up by:

for all unwanted snippets:
  open .sublime-snippet file
  add _ to value inside the <tabTrigger>
  save .sublime-snippet file

The problem is solved.