如何在 Sublime Text 中打开和关闭完成

How to turn completions on and off in Sublime Text

完成是有用的,但有时它们会妨碍。有什么方法可以打开和关闭它们吗?

屏幕截图中的框显示了 Sublime Text 完成 功能。

要关闭 完成,请在您的用户 Preferences.sublime-settings 文件中将 auto_complete 设置设为 false。可以使用 Preferences --> Settings 从菜单访问用户设置文件,在打开的 window 的右栏中编辑文件。只需添加这一行:

"auto_complete": 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": "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,

您可以像这样设置一个键绑定来打开和关闭设置:

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

请注意,toggle_setting 命令不会更改 Preferences.sublime-settings 文件中的值,只会更改其在内存中的值。

您还可以设置 语法特定项目特定 设置是否默认启用 auto_complete