Skip to content

Instantly share code, notes, and snippets.

@discdiver
Last active April 17, 2024 18:16
Show Gist options
  • Save discdiver/9e00618756d120a8c9fa344ac1c375ac to your computer and use it in GitHub Desktop.
Save discdiver/9e00618756d120a8c9fa344ac1c375ac to your computer and use it in GitHub Desktop.
Common Jupyter Lab Keyboard Shortcuts

If you are on a Mac, substitute command for control. Don't type the + (it means press both keys at once).

Shortcuts when in either command mode (outside the cells) or edit mode (inside a cell):

  • Shift + Enter run selected cell or cells - if no cells below, insert a code cell below

  • Ctrl + B toggle hide/show left sidebar

  • Ctrl + S save and checkpoint

  • Ctrl + Shift + S save as

  • Ctrl + F find

Shortcuts when in command mode (outside the cells, no blinking cursor):

  • 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

  • B insert a new cell below the active cell

  • M make the active cell a Markdown cell

  • Y make the active cell a code cell

  • Shift + Up Arrow select the current cell and the cell above

  • Shift + Down Arrow select the current cell and the cell below

  • Ctrl + A select all cells

  • X cut the selected cell or cells

  • C copy the selected cell or cells

  • V paste the cell(s) which were copied or cut most recently

  • Shift + M merge multiple selected cells into one cell

  • DD (D twice) delete the active cell

  • 00 (Zero twice) restart the kernel

  • Z undo most recent command mode action

Shortcuts when in edit mode (inside a cell with a blinking cursor):

  • Esc enter command mode

  • Tab code completion (or indent if at start of line)

  • Shift + Tab tooltip help

  • Ctrl + Shift + - split the active cell at the cursor

The usual commands for code editors:

  • Ctrl + ] indent

  • Ctrl + [ dedent

  • Ctrl + / toggle comment

Plus the usual shortcuts for select all, cut, copy, paste, undo, etc.

@nbvso1
Copy link

nbvso1 commented Jul 1, 2021

In my system (with Norwegian keyboad), commenting works using the combination of Ctrl + '

@mrexito
Copy link

mrexito commented Aug 8, 2021

In my keyboard Ctrl + / to comment out doesn't function. The forward slash is above the 7 on the same key.

@pauwiersma
Copy link

Same here on Swiss QWERTZ keyboard, ctrl+shift+7 doesn't work

@nick-youngblut
Copy link

Is there a keyboard shortcut to switch among the file browser, table of contents, etc?

@discdiver
Copy link
Author

@nick-youngblut Ctrl + B toggle hide/show left sidebar

@nick-youngblut
Copy link

Thanks @discdiver! ...but Ctrl + B doesn't switch to the TOC if the left sidebar is currently set to the file browser, extension manager, etc., right?

@llinfeng
Copy link

@nick-youngblut From what I know about assigning shortcuts in Jupyterlab, we first need to find the corresponding action from either the menu or the Command Platte. For example, here is what I use to resume the Alt+R mapping in newer Jupyterlab installation:

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

Then, to switch directly to the Table of Contents menu that resides in the sidebar, we need to find a way to switch to TOC without clicking on that button. For now, I don't find anything relevant.


There is a clunky way to achieve it: use AutoHotKey to assign a Jupyterlab-only shortcut (say, Ctrl+T) that searches for the pixel patterns of that TOC button. For pixel search, I would use FindText. Alternatively, one can write a Userscript with a proper scope (domain), and simulate the mouse-click on the button with id="tab-key-5" and assign such action to a keyboard shortcut to be loaded using that user script.

@mrexito
Copy link

mrexito commented Jul 6, 2022

What are the shortcuts for

  1. jumping to the top of the notebook
  2. jumping to the end of the notebook
  3. accessing the keyboard shortcuts
  4. running all cells

@llinfeng
Copy link

llinfeng commented Jul 6, 2022

@mrexito RE: #1 and #2, you'll find this helpful - https://pypi.org/project/jupyterlab-vim/.

@discdiver
Copy link
Author

discdiver commented Oct 11, 2022 via email

@Masoud-Mahdavii
Copy link

is which keys that show shortcut keys?

@garritanoo
Copy link

Shortcuts when in command mode (outside the cells, no blinking cursor):
Shift + M, join the cells

@devsutong
Copy link

Why H doesn't work to see list of all keyboard shortcuts like in notebook?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment