在我的 sublime-keymap 文件中,我已经有了这个:
{ "keys": ["shift+space"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[ )'\"\\}\\]>: ]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
}
因此,当我的光标位于这些字符中的任何一个之前)}]:;> shift+space 会将光标向右移动,从而跳过字符。这是非常有用的并且已经众所周知。
现在我在想如果有逆也很好。想象一下,我刚刚跳过了一个结束 },但我记得我仍然在 {} 中输入了一些内容。如果能够再次执行 shift+space 并回到 {} 内,那就太好了。
我正在检查这个文档,但我尝试的一切都没有奏效。
对此有任何帮助或想法吗?谢!
编辑:基于正确答案:
所以,根据@skuroda 的回答,这就是我想出的。有关更多信息,请阅读他的答案下方的评论。
{ "keys": ["shift+space"], "command": "move", "args": {"by": "characters", "forward": false}, "context":
[
{ "key": "preceding_text", "operator": "regex_contains", "operand": "[)'\"\\}\\]>,\\;:]$", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
{ "keys": ["shift+space"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)'\"\\}\\]>,\\;:]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
代码的顺序很重要(preceding_text 命令必须在 following_text 之前)。
更新:我想我找到了一个更简单更好的解决方案:
{ "keys": ["shift+space"], "command": "move", "args": {"by": "characters", "forward": true} },
{ "keys": ["super+shift+space"], "command": "move", "args": {"by": "characters", "forward": false} }
因此,上下文在这里并不重要。Shift + Space
将前进一个字符,CMD + Shift + Space
将返回一个字符。纯粹的喜悦!