如何使用Sublime keymap将光标发送到下一行

时间:2016-05-19 11:10:11

标签: sublimetext3 cursor-position sublimerepl

我正在使用keymap通过按ctrl + enter来执行sublime repl中的当前行。光标保持在同一行。我需要将什么添加到键映射中,以便光标跳转到下一行(就像在RStudio中发生的那样)?

[
    { "keys": ["ctrl+enter"], "command": "repl_transfer_current", "args": {"scope": "lines"}}
]

1 个答案:

答案 0 :(得分:4)

我找到了一种使用python脚本插件的方法。显然,Sublime默认情况下不能在单个键映射下运行多个命令。 我使用了这里的方法:https://forum.sublimetext.com/t/run-multiple-commands-command/6848

步骤如下:

  1. Sublime - 工具 - 开发者 - 新插件
  2. 复制来自run_multiple_commands.py的代码:https://gist.github.com/bgmort/7ae52ea4270f1c404321c20d1b97733c#file-run_multiple_commands-py 并以与github:run_multiple_commands.py

    相同的名称保存文件
    1. Sublime - 首选项 - 键绑定用户
    2. 代码:

      {
        "keys": ["ctrl+enter"],
        "command": "run_multiple_commands",
        "args": {
          "commands": [
            { "command": "repl_transfer_current", "args": {"scope": "lines"} },
            { "command": "move", "args": {"by": "lines", "forward": true} }
          ]
        }
      }
      
      如果文件为空,

      或另外添加[]:

      [{
        "keys": ["ctrl+enter"],
        "command": "run_multiple_commands",
        "args": {
          "commands": [
            { "command": "repl_transfer_current", "args": {"scope": "lines"} },
            { "command": "move", "args": {"by": "lines", "forward": true} }
          ]
        }
      }]