8

I happen to use "Run Selected Text or Current Line in Console" command a lot under the "Run" menu in JupyterLab. How can we configure a custom keyboard shortcut in JupterLab/Jupyter notebook for this?

Vinay
  • 1,149
  • 3
  • 16
  • 28

2 Answers2

10

For JupyterLab

Go to Settings and choose Advanced Settings editor. Under the Keyboard shortcuts tab, copy the entire System Defaults content to User Preferences column and find section containing:

"command": "notebook:run-in-console",
      "keys": [
        ""
      ],

Add the key combination you wish and save, e.g:

"keys": [
  "F12"
],
vs97
  • 5,765
  • 3
  • 28
  • 41
3

Once JupterLab is open click the Settings dropdown menu. Select Advanced Settings Editor. Select Keyboard Shortcuts. You’ll see a dictionary for each option in the System Defaults panel. There are a bunch of options, so you might want to Command + F (Ctrl + F on Windows) to find the one you want. Copy the code of the one you want to override. Here’s the section for restart-and-run-all.

{"shortcuts": 
    [
        {
            "command": "runmenu:restart-and-run-all",
            "keys": [
                "Ctrl Shift R"
            ],
            "selector": "[data-jp-code-runner]"
        }
    ]
}

I suggest making sure you aren’t overriding another JupyterLab keyboard shortcut by searching the System Defaults Panel for your new key combination. And there you have it. Press Command + S (Ctrl + S on Windows) to save, open a notebook file, and try out your new keyboard shortcut!

Source

Chandler B
  • 111
  • 7