【问题标题】:Is it possible to stop tab-autocomplete in Sublime Text 2?是否可以在 Sublime Text 2 中停止制表符自动完成?
【发布时间】:2014-10-12 19:07:17
【问题描述】:

我已经使用 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,

我对 cme​​ts 的解读是,这应该会导致自动完成仅在我按 Enter 时插入其建议,这正是我想要的。但是,它继续在选项卡上这样做。我是否设置错误,或者 ST2 中是否存在阻止用户关闭自动完成功能的错误?

编辑

为了澄清,我真的希望自动完成功能只有在我按下向下箭头选择列表中的某些内容然后按 Enter 时才会发生。没有我先选择一个项目,enter 和 tab 都不应该启动自动完成。

【问题讨论】:

    标签: sublimetext2 sublimetext


    【解决方案1】:

    我正在使用 Sublime Text 3 并添加 "tab_completion": false, 进入 Preferences -> Settings-User 就可以了。

    【讨论】:

      【解决方案2】:

      经过几十次设置排列,我能够让 Sublime Text 3 表现出我想要的样子:

      • 当出现自动完成时,tab 会忽略它并进入一个 tab。
      • Enter 接受自动完成。

      对我来说似乎是显而易见的选择。

      首选项 > 设置

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

      首选项 > 键绑定

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

      【讨论】:

      • 在 Sublime 3 中工作,谢谢!
      【解决方案3】:

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

      在您的用户设置中添加:

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

      【讨论】:

        猜你喜欢
        • 2015-03-14
        • 1970-01-01
        • 1970-01-01
        • 2015-07-31
        • 1970-01-01
        • 2013-07-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多