在 Sublime Text 2 中,如何进行键映射以将光标向上或向下移动多行?

在 Sublime Text 2 中,如何进行键映射以将光标向上或向下移动多行?

我正在尝试以下键映射,但它每次只能将光标向上移动一行。我希望它每次移动 10 行。似乎“amount”参数被忽略了。

{ "keys": ["alt+down"], "command": "move", "args": {"by": "lines", "forward": true, "amount": 10.0} },
{ "keys": ["alt+up"], "command": "move", "args": {"by": "lines", "forward": false, "amount": 10.0} }

答案1

您可以创建一个通过键绑定调用的插件,然后该插件可以收集当前行并将其向下或向上移动。

在官方 Sublime 论坛上发帖有一个如何使用插件来回移动 10 行的示例。

答案2

为了实现这一点,我编写了一个插件:https://github.com/sflip/SublimeMoveMore

答案3

我也成功使用了多个命令 命令实现绑定中的命令连接。

您不需要为此使用单独的插件,但您需要重复执行相同的命令。以下是我的绑定文件中的示例。

{
    "keys": ["H"],
    "command": "run_multiple_commands",
    "args": {
        "commands": [
            {"command": "set_motion", "args": {
            "motion": "vi_move_by_characters_in_line",
            "motion_args": {"forward": false, "extend": true }}},
            {"command": "set_motion", "args": {
            "motion": "vi_move_by_characters_in_line",
            "motion_args": {"forward": false, "extend": true }}},
            {"command": "set_motion", "args": {
            "motion": "vi_move_by_characters_in_line",
            "motion_args": {"forward": false, "extend": true }}},
            {"command": "set_motion", "args": {
            "motion": "vi_move_by_characters_in_line",
            "motion_args": {"forward": false, "extend": true }}},
            {"command": "set_motion", "args": {
            "motion": "vi_move_by_characters_in_line",
            "motion_args": {"forward": false, "extend": true }}},
            {"command": "set_motion", "args": {
            "motion": "vi_move_by_characters_in_line",
            "motion_args": {"forward": false, "extend": true }}},
            {"command": "set_motion", "args": {
            "motion": "vi_move_by_characters_in_line",
            "motion_args": {"forward": false, "extend": true }}},
            {"command": "set_motion", "args": {
            "motion": "vi_move_by_characters_in_line",
            "motion_args": {"forward": false, "extend": true }}},
            {"command": "set_motion", "args": {
            "motion": "vi_move_by_characters_in_line",
            "motion_args": {"forward": false, "extend": true }}},
            {"command": "set_motion", "args": {
            "motion": "vi_move_by_characters_in_line",
            "motion_args": {"forward": false, "extend": true }}},
        ]
    },
    "context": [{"key": "setting.command_mode"}]
},

我知道这看起来很糟糕,但这显然是让光标向后移动 10 行的标准方法。

如果有某种方法可以找出在复古模式下输入“10h”会执行的命令调用,那就更优雅了。

相关内容