Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to stop tab-autocomplete in Sublime Text 2?

I've been using Sublime Text 2 for about 3 weeks, considering it for my new IDE. However, one feature is driving me absolutely crazy.

Autocomplete pops up about 5 times as often as I need it, which would be fine if I could just type away and ignore it. However, it continually inserts whatever it is suggesting when I hit the tab key, and the tab key is used multiple times on each line to format code. This leads to me having to undo autocomplete on almost every line of code I type.

I went into the preferences, which is just a giant text file, and made the following changes:

// 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": false,

// 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": "source - comment",

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

My reading of the comments is that this should cause autocomplete only to insert its suggestions when I hit enter, which is what I want. However, it continues to do so on a tab. Have I set something incorrectly, or is there a bug in ST2 that prevents the user from turning off autocomplete?

EDIT

To clarify, I'd really like autocomplete to only occur if I press my down arrow to select something in the list and then hit enter. Neither enter nor tab should initiate an autocomplete without me first selecting an item.

like image 510
Nicholas Avatar asked Oct 12 '14 19:10

Nicholas


3 Answers

I'm using Sublime Text 3 and I add "tab_completion": false, into Preferences -> Settings-User and it works.

like image 179
chaosink Avatar answered Oct 11 '22 13:10

chaosink


After dozens of settings permutations, I was able to get Sublime Text 3 to behave how I wanted:

  • When an autocomplete appears, tab ignores it and enters a tab.
  • Enter accepts an autocomplete.

Seems like the obvious choice to me.

Preferences > Settings

{
    "tab_completion": false,
    "auto_complete_commit_on_tab": false
}

Preferences > Key Bindings

[
    { "keys": ["tab"], "command": "insert", "args": {"characters": "\t"}, "context": 
        [
            { "key": "auto_complete_visible" }
        ]
    }
]
like image 25
neokio Avatar answered Oct 11 '22 13:10

neokio


I know it's an old question, but I had the same problem with no answer available. Here is my solution. Try following settings (works only altogether):

in your user settings add:

// disable auto complete to be triggered automatically when typing.
"auto_complete": false,

// pressing tab calls completion menu, not autocomplete + it still works as ident
"tab_completion": true,

And in the user keymap:

    // show autocomplete on tab, not automatically, commit on enter.
{ "keys": ["tab"], "command": "auto_complete", "args": {"default": "\t", "exact": false},
    "context":
    [
        { "key": "setting.tab_completion", "operator": "equal", "operand": true },
        { "key": "preceding_text", "operator": "regex_match", "operand": ".*[^0-9][^\r ^\n ^\t ^\f]", "match_all": false },
    ] 
},
{ "keys": ["tab"], "command": "auto_complete", "args": {"default": "\t", "exact": false},
    "context":
    [
        { "key": "setting.tab_completion", "operator": "equal", "operand": true },
        { "key": "preceding_text", "operator": "regex_match", "operand": "[][a-z]", "match_all": false },
    ] 
},
like image 41
Ufos Avatar answered Oct 11 '22 12:10

Ufos