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?
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"
],
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With