0

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

为了澄清我想要的东西:

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
}
4

1 回答 1

1

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

    { "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 },
      ]
    },
于 2021-10-22T18:49:13.960 回答