1

After update from sublime text 3 autocomplete triggers on TAB and ENTER

Its hard to use snippets like foreach in PHP

foreach($mark as $mark => $mark) {
    $mark
}

In sublime text 3 after TAB you jump to next mark, but now autocomplete happens

I tried some settings

"tab_completion": false,
"auto_complete_commit_on_tab": false,

Not working

Found key binding

{ "keys": ["tab"], "command": "commit_completion", "context":
    [{ "key": "auto_complete_visible" }]
},

Dont know how to remove it

Pls help, its too hard to use Sublime text now

Skywave
  • 111
  • 3

4 Answers4

2

I tried some solutions, there are not perfect. There is a worked solution: [SOLVED] ST3: “tab_completion”: false does not work, but now I want to provide mine (inspired by this link ↑, thanks for @OdatNurd).

1. Preferences -> Key Bindings

2. Search '"keys": ["tab"]' at left window, then you get a group of result. It's look like this for me:

    { "keys": ["tab"], "command": "auto_complete", "args": {"mini": true, "default": "\t"},
        "context":
        [
            { "key": "auto_complete_visible", "operand": false },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "setting.tab_completion", "operator": "equal", "operand": true },
            { "key": "preceding_text", "operator": "regex_match", "operand": ".*\\w", "match_all": true },
        ]
    },
    { "keys": ["tab"], "command": "expand_snippet", "context":
        [{ "key": "has_snippet" }, ]
    },
    { "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 }
        ]
    },
    { "keys": ["tab"], "command": "indent", "context":
        [{ "key": "text", "operator": "regex_contains", "operand": "\n" }]
    },
    { "keys": ["tab"], "command": "move", "args": {"by": "lines", "forward": true}, "context":
        [
            { "key": "overlay_has_focus", "operator": "equal", "operand": true }
        ]
    },
    { "keys": ["tab"], "command": "next_field", "context":
        [{ "key": "has_next_field", "operator": "equal", "operand": true }]
    },
    { "keys": ["tab"], "command": "commit_completion", "context":
        [{ "key": "auto_complete_visible" }]
    },

(I don't want to imply what it should look like, because different sublime versions will have different settings.)

3. COPY them all into the right window.

4. DELETE (or just Comment Out) both "auto_complete" block and "commit_completion" block at right the window, and don't change anything else. Now, my User Keybindings like this:

  // Disable all autocompletion and tab completion. This overrides the default
  // binding for this key.
  { "keys": ["tab"], "command": "insert", "args": {"characters": "\t"} },
  // { "keys": ["tab"], "command": "auto_complete", "args": {"mini": true, "default": "\t"},
  //   "context":
  //   [
  //     { "key": "auto_complete_visible", "operand": false },
  //     { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
  //     { "key": "setting.tab_completion", "operator": "equal", "operand": true },
  //     { "key": "preceding_text", "operator": "regex_match", "operand": ".*\\w", "match_all": true },
  //   ]
  // },
  { "keys": ["tab"], "command": "expand_snippet", "context":
    [{ "key": "has_snippet" }, ]
  },
  { "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 }
    ]
  },
  { "keys": ["tab"], "command": "indent", "context":
    [{ "key": "text", "operator": "regex_contains", "operand": "\n" }]
  },
  { "keys": ["tab"], "command": "move", "args": {"by": "lines", "forward": true}, "context":
    [
      { "key": "overlay_has_focus", "operator": "equal", "operand": true }
    ]
  },
  { "keys": ["tab"], "command": "next_field", "context":
    [{ "key": "has_next_field", "operator": "equal", "operand": true }]
  },
  // { "keys": ["tab"], "command": "commit_completion", "context":
  //   [{ "key": "auto_complete_visible" }]
  // },
  1. Enjoy it . This solution won't break the snippets index, and you can commit completion with enter.
Qiu Weishi
  • 33
  • 9
1

I believe what you're looking for is tab_completion: false. When I added this to my preferences, and typed some text and hit tab, it no longer pops up an auto-complete modal, and just inserts \t like I wanted it to.

3DigitDev
  • 11
  • 1
0

Not sure how portable the solution is (especially with regards to different versions of Sublime). I'm on Linux (Fedora 34) and using the latest Sublime from their official repo (build 4121 at time of writing) with a registered license.

But I think the issue I had was similar to yours (your post was the first duckduckgo result for "sublime disable auto complete on tab"). Basically, I already had auto_complete and auto_match_enabled both set to false in my preferences file but was still seeing that if I had some text such as:

async:      false,

and I placed my cursor after the "c" in async and hit TAB that it would try to autocomplete this to some word that began with "async". But the behavior that I wanted was for it to literally insert a TAB (\t) character instead of using TAB as auto-completion trigger.

After reading this post, I tried "auto_complete_commit_on_tab": false which didn't seem to work for me either. I couldn't figure out how to override the selector keybinding so I started disabling a lot of auto-complete settings in a "shotgun approach". I did search online for settings but mostly just went off of the descriptions in the global / left-hand side of the settings file.

I'm not sure of the exact setting that did it but it now behaves as I wanted with TAB just inserting a \t character. I suspect that "auto_complete_size_limit": 1 may have been the most relevant setting but I'm not sure.

Here is my preferences file for reference:

{
    "always_prompt_for_file_reload": true,
    "atomic_save": true,
    "auto_close_tags": true,
    "auto_complete": false,
    "auto_complete_size_limit": 1,
    "auto_complete_selector": "",
    "auto_complete_commit_on_tab": false,
    "auto_complete_with_fields": false,
    "auto_complete_cycle": false,
    "auto_complete_use_index": false,
    "auto_complete_use_history": false,
    "auto_complete_trailing_symbols": false,
    "auto_complete_include_snippets": false,
    "auto_complete_include_snippets_when_typing": false,
    "auto_match_enabled": false,
    "copy_with_empty_selection": false,
    "drag_text": false,
    "detect_indentation": true,
    "ensure_newline_at_eof_on_save": true,
    "font_size": 15,
    "highlight_modified_tabs": true,
    "show_encoding": true,
    "show_line_endings": true,
    "tab_completion": false,
    "translate_tabs_to_spaces": false,
    "trim_automatic_white_space": true,
    "trim_trailing_white_space_on_save": true,
    "update_check": false,
    "close_find_after_find_all": false,
    "close_find_after_replace_all": false
}
zpangwin
  • 1,082
  • 1
  • 12
  • 17
0

By default, in settings, it says:

// Shift+tab can be used to insert an explicit tab when tab_completion is enabled.

Just thought I'd post the simple workaround that exists by default, where you don't need to disable tab auto completion

premg
  • 1
  • 2