【问题标题】:Sublime text autocomplete wth tab key only after character仅在字符后使用 Tab 键自动完成 Sublime 文本
【发布时间】:2018-10-18 15:42:16
【问题描述】:

可以将 Sublime text 3 配置为仅在光标位于字符之后而不是之前时按 Tab 键时自动完成吗?

我想避免 -done 补全,而是添加一个制表符空间。

【问题讨论】:

    标签: autocomplete sublimetext3


    【解决方案1】:

    如您所见,ST 的默认行为是“插入最佳补全”,此时插入符号前面只有一行空格。

    幸运的是,ST 非常可定制,我们可以根据您的需要覆盖此行为。

    为此,请将其添加到您的用户键绑定中:

    { "keys": ["tab"], "command": "indent",
        "context":
        [
            { "key": "preceding_text", "operator": "regex_match", "operand": "^\\s*$", "match_all": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "following_text", "operator": "not_regex_match", "operand": "^$", "match_all": true },
            { "key": "auto_complete_visible", "operator": "equal", "operand": false },
        ]
    },
    { "keys": ["tab"], "command": "insert", "args": { "characters": "\t" },
        "context":
        [
            { "key": "preceding_text", "operator": "regex_match", "operand": "^\\s*$", "match_all": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true },
            { "key": "auto_complete_visible", "operator": "equal", "operand": false },
        ]
    },
    

    这告诉 ST,当你按下 Tab 时,它应该在满足以下条件时缩进文本: - 没有选择 - 插入符号位于行首或仅以空格开头(即缩进) - 在插入符号之后(/ 右侧)有一些文本 - 自动完成弹出窗口不可见

    此外,当所有这些条件都为真时,除了插入符号后的行上有文本,我们告诉 ST 插入一个制表符。注意:如果您使用空格进行缩进,ST 会将其转换为正确的空格数。

    (当您在多行选择中按 Tab 时的旧缩进行为将保留,当我们的条件不满足时其他默认绑定也将保留。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-19
      • 2015-09-13
      • 2015-12-06
      • 1970-01-01
      • 2019-10-30
      • 2013-04-04
      • 2020-11-25
      相关资源
      最近更新 更多