Sublime Text3配置C++时设置解析错误求助
Sublime Text 括号自动补全跳转的JSON解析错误修复
你提供的键绑定代码出现JSON解析错误,核心问题是正则表达式中的特殊字符未正确转义,以及JSON字符串语法断裂。以下是修复方案:
错误根源
- JSON字符串中,双引号(
")和反斜杠(\)必须转义,否则会被解析器误判为字符串结束或无效转义序列 - 原代码中
"[(['\"]"行的结尾双引号未转义,直接导致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字符串提前结束) - 确保所有括号、逗号的语法闭合正确
操作步骤
- 打开Sublime Text,点击顶部菜单栏
Preferences > Key Bindings - 将右侧用户配置区的原有代码替换为上述修复后的代码
- 保存文件,解析错误即可消失
内容的提问来源于stack exchange,提问作者Chaitanya Deshmukh
相关产品推荐
相关产品推荐

