The keyboard shortcuts make you fast as ninja. The faster you can provide the software to analyze data or solve engineering problem the better. In this article we show you Jupyter Notebooks keyboard shortcuts that you need to know. Learning shortcuts might take a while. We created a PDF ready to print with shortcuts for Mac, Windows and Linux users. It is available at the end of the article.
Two modes for shortcuts
There are two modes of Jupyter Notebook for accepting shortcuts:
- edit mode,
- command mode,
The edit mode is available when we have coursor blinking in the cell. You can switch it on by clicking in the cell text area. If you click in the cell but outside the text area, then you need to hit
Enter on the keyboard to activate the edit mode. The exit from edit mode please press
The command mode is available when the coursor is not blinking in the cell text are. You can switch it on with
Esc button. You will see that the border color around the cell is changing when you switch the modes.
There are some shortcuts that work in both modes, and there are shortcuts that only work in the selected mode.
If you are a Mac users please use the following mapping for (
- a command key
- a key
- a key
Shortcuts for both modes
Ctrl + Enter- it executes the current cell. One of the most important shortcuts :)
Alt + Enter- it executes the current cell and insert a code cell below.
Shift+Enter- it executes the current cell and switch the focus to the cell below. If you are in the last cell, then a new code cell will be inserted at the end.
Ctrl+S- it saves the notebook and checkpoint.
Shortcuts for command mode
Enterswitch to edit mode
h- it shows all keyboard shortcuts.
Up- it changes the selected cell to the above cell,
Down- it changes the selected cell to the below cell,
a- inserts the code cell above,
b- inserts the code cell below,
x- cuts the selected cell,
c- copies the selected cell,
v- pastes the cell below,
Shift+v- pastes the cell above the current cell,
d- deletes the selected cell,
z- undoes the cell deletion,
y- changes the cell type to Code,
m- changes the cell type to Markdown,
r- changes the cell type to Raw,
Shift + Space- scrolls notebook up,
Space- scrolls notebook down,
p- opens the command pallete. You can search for any command there and execute.
Shortcuts for edit mode
Shortcuts for edit mode are very similar as in the most text editors in advance IDEs.
Esc- exits from edit mode to command mode,
Tab- code completion,
Ctrl + ]- increases indentation,
Ctrl + [- decreases indendation,
Ctrl + a- select all text in the code,
Ctrl + z- undoes previous action,
Ctrl + Home- goes to the cell start,
Ctrl + End- goes to the cell end,
Ctrl + Right- goes one word right,
Ctrl + Left- goes one word left,
Add custom shortcuts
You can easily add a custom shorcut. Please go to Help -> Edit Keyboard Shortcuts. It will open a dialog where you can search for a command and write a shortcut. You need to separate a keys with
-. I want to add a custom shortcut
Ctrl + 5 for
restart kernel and run all cells, so I need to write
Ctrl-5. Please check the animation below:
Shortcuts in PDF
Below are images with links for Jupyter Notebook shortcuts cheatsheets in PDF format that are perfect for print (please click on selected image to download PDF version). You can find all PDFs in our repository. Enjoy! :)
Shortcuts for Mac users in color
Shortcuts for Mac users in gray
Shortcuts Windows or Linux users in color
Shortcuts Windows or Linux users in gray
The keyboard shortcuts can greatly speed-up the process of software development. The more shortcuts you remember and use the more productive you are. The Jupyter Notebook provides two modes for accepting shortcuts. The command mode helps you navigate through the cells and notebook. The edit mode is for text and code editing.