是否可以在Sublime Text 2中停止制表符自动完成功能?

时间:2014-10-12 19:07:18

标签: sublimetext2 sublimetext

我已经使用Sublime Text 2大约3周了,考虑到我的新IDE。然而,一个特点让我绝对疯狂。

自动完成弹出的频率大约是我需要的5倍,如果我可以输入并忽略它就没问题。但是,当我按Tab键时,它会不断插入它建议的内容,并且每行上多次使用tab键来格式化代码。这导致我必须在我输入的几乎所有代码行上撤消自动完成。

我进入了首选项,这只是一个巨大的文本文件,并进行了以下更改:

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

我对这些评论的阅读是,这应该导致自动完成仅在我按Enter键时插入其建议,这就是我想要的。但是,它会继续在选项卡上执行此操作。我是否设置错误,或ST2中是否存在阻止用户关闭自动完成的错误?

修改

为了澄清,我真的很喜欢自动完成,只有当我按向下箭头选择列表中的某些内容然后按回车键时才会出现。在没有我首先选择项目的情况下,输入和制表符都不会启动自动完成。

3 个答案:

答案 0 :(得分:6)

我知道这是一个老问题,但我有同样的问题,没有答案可用。这是我的解决方案。 尝试以下设置(仅适用):

在您的用户设置中添加:

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

在用户键映射中:

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

答案 1 :(得分:6)

我使用Sublime Text 3并添加 "tab_completion": false, 进入首选项 - &gt;设置 - 用户,它的工作原理。

答案 2 :(得分:6)

在几十种设置排列之后,我能够获得Sublime Text 3来表现我的想法:

  • 当出现自动填充时,标签会忽略它并进入标签页。
  • Enter接受自动填充。

对我来说似乎是一个明显的选择。

偏好设置&gt;设置

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

偏好设置&gt;关键绑定

[
    { "keys": ["tab"], "command": "insert", "args": {"characters": "\t"}, "context": 
        [
            { "key": "auto_complete_visible" }
        ]
    }
]