改变Sublime Text 3 Vintage Mode中“}”快捷方式的行为

问题描述 投票:1回答:2

在Sublime Text 3 Vintage Mode中,键盘快捷键“}”执行以下命令:

{
  "keys": ["}"],
  "command": "set_motion",
  "args": {
    "motion": "move",
    "motion_args": {
      "by": "stops",
      "empty_line": true,
      "extend": true,
      "forward": true,
      "separators": "",
      "word_begin": false
    }
  }
}

我找不到set_motion的好文档,我不知道从哪里开始实现这个。

如何更改行为,以便不移动到下一个空行,而是移动到只有空格的下一行?

谢谢!

sublimetext2 sublimetext sublimetext3
2个回答
0
投票

无法真正帮助set_motion命令,但通过插件自己做这件事不应该是坏事。首先,这里是ST3 API文档的link。你将创建一个sublime_plugin.TextCommand。特别感兴趣的是view#selview#lineview#substr

view#sel将为您提供光标的位置。

view#line传入一个点(最初从view#sel检索)将创建给你一个整个线的区域。

view#substr获取该区域(来自view#line的结果)并返回该行中字符的字符串。您可以使用正则表达式查看该行是否仅包含空格,并适当放置光标。如果该行不符合要求,您可以增加该区域中的第二个点以移动到下一行。

希望这有助于让您朝着正确的方向前进。


0
投票

以下是软件作者关于“by”的选项可用性的评论:“停止”https://forum.sublimetext.com/t/restoring-st2-cursor-move-by-word-behaviour-in-st3-on-os-x/14035

If you need more control, then using the move command with “by”: “stops” should allow more configurability. When using stops, you need to tell the command which logical units to stop on. The options are:

"word_begin": false,
"word_end": false,
"punct_begin": false,
"punct_end": false,
"sub_word_begin": false,
"sub_word_end": false,
"line_begin": false,
"line_end": false,
"empty_line": false,
© www.soinside.com 2019 - 2024. All rights reserved.