How to disable sublime text 4 Context-Aware Suggestions

Viewed 226

In sublime text 4, it will suggest context word, I want disable that feature.

for example, I type wh, I will get a "while snippet".

enter image description here

when file have "while" word, I type wh,I will get "while" word and "while snippet",I have to move down to select "while snippet".

enter image description here

"auto_complete_use_index": false, do not work.

Is there a way to disable the first "while" word.

2 Answers

If you don't want to inhibit word/buffer completions entirely, you can create a plugin like the following (Tools menu -> Developer -> New Plugin... and replace the placeholder with the following):

import sublime, sublime_plugin


class InhibitWordCompletionsEventListener(sublime_plugin.EventListener):
    def on_query_completions(self, view, prefix, locations):
        return sublime.CompletionList([sublime.CompletionItem.command_completion('', 'noop')], sublime.INHIBIT_WORD_COMPLETIONS)

Be sure to save it in the folder ST recommends (i.e. Packages/User/) with a .py extension.

Then, when you type wh, ST won't suggest the word while, just the Python snippet.

NOTE: this feels like a bit of a hack, it may not work this way in future builds of ST, but I tested on 4125 and it works there.


If you do want to disable buffer completions entirely, see How to remove words in the current buffer from Sublime Text 4 autocomplete list.

On my test for version 4121,I get the following results:

"auto_complete_include_snippets": false, --OK
"auto_complete_use_index": false,  -- no work
"index_files": false,  -- no work

Given this, you can try the setting:

"auto_complete_include_snippets" 
Related