在 Sublime text 4 中输入相同字符时覆盖下一个字符

Override next character when the same is typed in Sublime text 4

有没有办法在键绑定文件中设置新规则,当我键入已经在光标之后的字符时,它会被覆盖。

阐明我想要什么:

if (ABC === XYZ) { // when I place cursor right after "XYZ" and type ")" mark, it will not be inserted and cursor jump right after the ")" which is already there
  echo "equals"; // when I place cursor right ater "equals" and type ";" mark, it will not be inserted and cursor jump right after the semicolon which is already there. When I type it again then, it will be inserted as usual
}

是的,这是可能的 - 当您按下要跳过的键时,检查插入符号右侧的字符是否与您按下的键相同,如果是则移动到它上面。下面是分号和右括号的具体绑定:(不幸的是,它涉及到一些重复,因为上下文不能在不编写一些插件代码的情况下根据按下的键获取参数)

    { "keys": [";"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
      [
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^;", "match_all": true },
      ]
    },
    { "keys": [")"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
      [
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^\)", "match_all": true },
      ]
    },