4

I am using the keymap to execute the current line in sublime repl by hitting ctrl+enter. The cursor remains on the same line. What do I need to add to the keymap so the cursor would jump to the next line (as what happens in RStudio)?

[
    { "keys": ["ctrl+enter"], "command": "repl_transfer_current", "args": {"scope": "lines"}}
]
dom
  • 321
  • 2
  • 8

1 Answers1

4

I found a way to do it using a python script plugin. Apparently, Sublime by default does not have the option of running multiple commands under a single keymap. I used the method from here: https://forum.sublimetext.com/t/run-multiple-commands-command/6848

the steps are the following:

  1. Sublime - Tools - Developer - New Plugin

copy code from run_multiple_commands.py found here: https://gist.github.com/bgmort/7ae52ea4270f1c404321c20d1b97733c#file-run_multiple_commands-py and save the file under the same name as on github: run_multiple_commands.py

  1. Sublime - Preferences - Key Bindings User

code:

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

or additionally add [ ] if the file is empty:

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