You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Sublime Text3配置C++时设置解析错误求助

Sublime Text 括号自动补全跳转的JSON解析错误修复

你提供的键绑定代码出现JSON解析错误,核心问题是正则表达式中的特殊字符未正确转义,以及JSON字符串语法断裂。以下是修复方案:

错误根源

  1. JSON字符串中,双引号(")和反斜杠(\)必须转义,否则会被解析器误判为字符串结束或无效转义序列
  2. 原代码中"[(['\"]"行的结尾双引号未转义,直接导致JSON语法断裂

修复后的代码

{ "keys": ["enter"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
    [
        { "key": "following_text", "operator": "regex_contains", "operand": "^[)\\]'\"", "match_all": true },
        { "key": "preceding_text", "operator": "regex_contains", "operand": "[(\\['\"", "match_all": true },
        { "key": "auto_complete_visible", "operator": "equal", "operand": false }
    ]
},
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
    [
        { "key": "following_text", "operator": "regex_contains", "operand": "^[)\\]'\"", "match_all": true },
        { "key": "preceding_text", "operator": "regex_contains", "operand": "[(\\['\"", "match_all": true },
        { "key": "auto_complete_visible", "operator": "equal", "operand": false }
    ]
}

修改说明

  • 将正则中的\]改为\\](JSON中反斜杠需二次转义)
  • 将正则中的未转义双引号"改为\"(避免JSON字符串提前结束)
  • 确保所有括号、逗号的语法闭合正确

操作步骤

  1. 打开Sublime Text,点击顶部菜单栏 Preferences > Key Bindings
  2. 将右侧用户配置区的原有代码替换为上述修复后的代码
  3. 保存文件,解析错误即可消失

内容的提问来源于stack exchange,提问作者Chaitanya Deshmukh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 22:15:36