Jupyter Notebook

How Do I Use Keyboard Shortcuts in Jupyter?

Jupyter Notebook is a client-server application in which users can edit and run their notebook documents through a browser. The notebook documents that are created in Jupyter notebook consist of python or programming code and rich text elements such as paragraphs, images, links, and equations. When you work as a programmer, you like to use quick keyboard shortcuts to solve the routine work. These shortcuts help you to complete the programming code easier and quickly.

In Jupyter notebook, various functions and notebook cell options are available that you can manage efficiently using the keyboard shortcuts. Most of the users do not know how they can find and use these shortcuts in the Jupyter notebook. However, today you will learn about all the keyboard shortcuts used in the Jupyter notebook.

In this article, we will show you how you can use the keyboard shortcuts in the Jupyter notebook. These shortcuts are useful for both users as for Windows as well as for Linux.

Before exploring the Jupyter notebook shortcuts, you should know that there are two types of keyboard input modes available in the Jupyter notebook.

  • Command mode
  • Edit mode

Command Mode

Command mode activates when you select a new cell. This mode is usually used to perform the keyboard to notebook-level actions. In command mode, the grey border with a blue left margin indicates the cell.

Command Mode Shortcuts

Press the ‘Esc’ key to activate the command mode. The following keyboard shortcuts that are commonly used will help you to work with the command mode:

Keyboard shortcuts                        Actions
Enter Press ‘Enter’ to change the cell into the edit mode.
Up arrow  Select above cell
Down arrows Select below cell
H Display the all shortcuts list
Shift + Space Scroll notebook up
Space  Scroll notebook down
Shift + Up Select multiple cells above
Shift + Down Select multiple cells below
C Copy selected cells
X Cut the selected cells
V Paste cells below
Shift + V Paste cells above
D Press D twice deletes the selected cells
Open the command palette
Z Undo cell deletion action
A Insert cells above
B Insert cells below
Y Change the cell type to code
M Change cell type to markdown
S Save work and create checkpoints

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. The changes will be saved for later sessions.

Edit Mode

When you are typing in a cell, the edit mode activates in Jupyter notebook that indicates with green border.

Edit Mode Shortcuts

The most commonly used keyboard shortcuts for edit mode in Jupyter notebook that listed in a table:

Keyboard Shortcuts Actions
Esc Press ‘Esc’ to change the cell into the command mode.
Ctrl + A Select All
Ctrl + ] Code Indentation
Ctrl + [ Decrease indent
Tab For indentation or code completion
Shift + Tab tooltip
Ctrl + Z Undo changes
Ctrl + Home Move to the start of the cell
Ctrl + End Move to the End of the cell
Ctrl  + right arrow Move one word right
Ctrl + Left arrow Move one word left
Ctrl + Y  or

Ctrl + Shift + Z

Redo actions
Ctrl + Shift + P Open the command palette
Up arrow Move the cursor upward direction
Down arrow Move the cursor in a Downward direction

Some keyboard shortcuts are common in both types of input modes edit as well as in command mode, which are listed below:

Keyboard shortcuts Actions
Alt + Enter Execute the current cell and insert one cell below
Shift + Enter Execute the current cell and select the cell below
Ctrl + S Save and create checkpoints
Ctrl + Enter Execute the content of the selected cells

Access All Keyboard Shortcuts in Jupyter Notebook

To access all keyboard shortcuts in the Jupyter notebook, press ‘H’ or click on the ‘Help’ from the top menu as follows:

Now, choose the ‘keyboard shortcuts’ from the drop-down menu list.

The following keyboard shortcuts interface will display in the Jupyter notebook environment:

The above interface contains complete shortcuts keys information about all keyboard input modes (Command and Edit).

Search Keyboard Shortcuts Using the Command Palette

Using the command palette, you can search for a specific command or action by command name. Command palette is useful when you do not know about the shortcuts or you can explore the shortcut for a wanted command. This command palette is easily accessible in the Jupyter notebook. To open the command palette, click on the following icon:

To search for a specific command, just type the search keyword in the search bar as follows:

Conclusion

We have explained in this article two types of keyboard input modes are command mode and Edit mode. We have also listed the most commonly used keyboard shortcuts for both modes. These Jupyter keyboard shortcuts make our work easier. Try the all shortcuts in your Jupyter notebook for practice and let us know in case of any error. Thanks!

About the author

Samreena Aslam

Samreena Aslam holds a master’s degree in Software Engineering. Currently, she's working as a Freelancer & Technical writer. She's a Linux enthusiast and has written various articles on Computer programming, different Linux flavors including Ubuntu, Debian, CentOS, and Mint.