I've been using Jupyter Notebooks for a couple of years now. I've just headed over to Jupyter Lab, but I've found the lack of shortcuts to be a burden.
For example, I noticed that I can search for commands in the left hand palette. But I can't seem to easily bind them to a keyboard shortcut. Is this even possible?
For example, I want to collapse the current cell output with "O" and collapse all code cells with "Shift O".
Press 'Enter' to change the cell into the edit mode. You can modify the command mode shortcuts by using the help menu. Click on the 'Help' and choose the 'Edit keyboard shortcuts' option. The following interface shows in the Jupyter notebook where you can define new keyboard shortcuts.
Enter enter edit mode in the active cell. Scroll up with the up arrow. Scroll down with the down arrow. A insert a new cell above the active cell.
Starting with Jupyter Notebook 5.0, you can customize the command mode shortcuts from within the Notebook Application itself. Head to the ``Help`` menu and select the ``Edit keyboard Shortcuts`` item. A dialog will guide you through the process of adding custom keyboard shortcuts.
This question is answered on GitHub here. You can also look here for the correct command
names to enter in your keyboard shortcut user overrides because they are not always the same as what is shown in the Commands side-bar.
The following are some that I use:
{ "shortcuts": [ { "command": "notebook:hide-cell-outputs", "keys": [ "O" ], "selector": ".jp-Notebook:focus" }, { "command": "notebook:show-cell-outputs", "keys": [ "O", "O" ], "selector": ".jp-Notebook:focus" }, { "command": "notebook:hide-all-cell-outputs", "keys": [ "Ctrl L" ], "selector": ".jp-Notebook:focus" }, { "command": "notebook:hide-all-cell-code", "keys": [ "Shift O" ], "selector": ".jp-Notebook:focus" } ] }
which allows you to hide a cell output by pressing O
once and showing the cell output by pressing O
twice. The last one collapses all cell code with Shift + O
as you requested.
On keyboards shortcuts of advance settings this code works fine for moving cells up and down
{ // Move cell up "shortcuts": [ { "selector": ".jp-Notebook:focus", "command": "notebook:move-cell-up", "keys": [ "Alt ArrowUp" ] }, // Move cell down { "selector": ".jp-Notebook:focus", "command": "notebook:move-cell-down", "keys": [ "Alt ArrowDown" ] } ] }
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