Boris Paskhaver

Jupyter Notebook is a popular development environment in the Python data science community. It consists of a sequence of independent cells, each of which holds a chunk of Python code. When we execute a cell, Jupyter reveals the code’s output directly below the cell. The design encourages an active trial-and-error approach to data analysis. We can try one approach, observe the results, and modify our implementation accordingly.

Jupyter Notebook has dozens of keyboard shortcuts available to accelerate developer productivity. They assist with everything from everyday operations like copying and pasting to complex shortcuts for restarting the IPython kernel that powers the Notebook. In this article, we’ll introduce the most important Jupyter Notebook shortcuts you need to know to get up and running with this powerful technology.

Data Analysis with Pandas and Python

Last Updated April 2021

Bestseller
  • 177 lectures
  • All Levels
4.7 (14,802)

Analyze data quickly and easily with Python’s powerful pandas library! All datasets included — beginners welcome! | By Boris Paskhaver

Explore Course

1. Edit Mode

Jupyter Notebook operates in 2 modes: Command and Edit Mode.

Edit Mode is activated whenever we click into a cell. We use this mode to enter and edit text content into a cell. Jupyter highlights the currently active cell in green.

Edit mode in Jupyter notebook

Figure 1: Jupyter Notebook operating in Edit Mode

Press Shift + Enter to execute a cell and advance the cursor to the next available cell. If a cell does not exist, Jupyter will create one below.

The complementary Control + Enter shortcut executes a cell but does not advance to the next one.

executed Python code cell in Jupyter Notebook

Figure 2: An executed Python code cell in Jupyter Notebook

2. Command Mode

In Command Mode, our keyboard shortcuts translate to notebook-level actions. These actions are more “global” in nature and affect the Notebook as a whole.

To activate Command Mode, press the Escape key. Jupyter will outline the current cell in blue instead of green.

command mode jupyter notebook

Figure 3: Jupyter Notebook operating in Command Mode

Command Mode provides several edit keyboard shortcuts for common notebook-level actions. Here are some that I use daily:

Jupyter Notebook ships with an autosave feature, but it never hurts to save your work frequently. The Cmd + S (macOS) and Ctrl + S (Windows) shortcuts save the Notebook. You can also access the File menu at the top of the view and select Save and Checkpoint.

3. Restarting the IPython Kernel

Jupyter Notebook employs IPython to execute its Python code. IPython is an “enhanced” version of the original Python shell with extra features for debugging, history, magic methods, and more. See this article for some helpful tips for getting started with IPython.

At some point in your programming career, a piece of faulty code will trigger a Notebook slowdown. Thankfully, Jupyter makes it easy to recover from it.

The Kernel menu on the navigation menu offers options to Interrupt the currently executing code cell or Restart the IPython kernel completely. You can also restart the Notebook by pressing 0 twice in a row in Command Mode.

Kernel menu Ipython

Figure 4: The Kernel Menu in Jupyter Notebook

Note that the Restart options wipe all saved Python variables/constants from memory. You’ll need to re-execute the relevant cells again to bring them back into the program.

The Kernel menu offers additional options to clear cell output and run all cells in the Notebook. It’s a convenient way to “reset” when things go wrong.

4. The Command Palette

The Command Palette is an input box where you can issue commands to the Notebook. You no longer need to worry about remembering what navigation menu holds the command you’re looking for. Simply type a keyword, and Jupyter will filter the results to those that match the search term.

Press Command + Shift + P (macOS) or Ctrl + Shift P (Windows) to see the Command Palette. Click on a command to execute it.

command palette jupyter notebook

Figure 5: The Command Palette in Jupyter Notebook

5. Markdown

Markdown is a markup language for formatting text. We can use it to add paragraphs, headers, bullet lists, and more within our Jupyter Notebook.

In Command Mode, press the m key to designate a cell as a Markdown cell. If you need to convert a cell to a Python Code cell, press the y key instead.

Here are some helpful Markdown operations:

markdown jupyter notebook

Figure 6: A Markdown cell in Edit Mode

Once you’re done editing a Markdown cell, press Shift + Enter in Command Mode to execute it. Jupyter will display the formatted text output in the cell’s location.

markdown cell in edit mode jupyter notebook

Figure 7: A Markdown cell after execution

6. Even more shortcuts

Curious to learn more? In Command Mode, press the h key to reveal a modal of keyboard shortcuts. Some cool key bindings are available for operations like deleting the next word in line or moving the cursor to the start of the line. I frequently consult this list to learn new tips and tricks to accelerate my Notebook productivity.

keyboard shortcuts jupyter notebook, command mode

Figure 8: The keyboard shortcuts modal in Jupyter Notebook

Summary

Jupyter Notebook remains a powerful and effective tool for experimenting with Python code. It also allows you to tell a story with your code, the “how” and the “why.” You can use Markdown cells to describe your work and Python cells to show how you arrived at your result. Because of these benefits, many Udemy courses rely on Jupyter to teach Python. 

Additional Python development tools are available, like Spyder. I like to view each development environment as a separate tool in my technical toolbox. There is no harm in learning the ins and outs of as many tools as you want. Regardless of which environment you work with, I hope you continue to make your work more efficient. See you next time!

Page Last Updated: May 2021

Top courses in Data Analysis

The Data Science Course 2021: Complete Data Science Bootcamp
365 Careers, 365 Careers Team
4.6 (98,232)
Bestseller
Learning Python for Data Analysis and Visualization
Jose Portilla
4.4 (16,766)
Bestseller
Microsoft Excel - Advanced Excel Formulas & Functions
Maven Analytics, Chris Dutton
4.7 (54,687)
Bestseller
Data Analysis with Pandas and Python
Boris Paskhaver
4.7 (14,802)
Bestseller
Data Analysis Essentials Using Excel
Symon He, Travis Chow
4.5 (7,554)
Complete Introduction to Google Data Studio 2021 Edition
Ian Littlejohn
4.7 (3,063)
Bestseller
Statistics for Data Analysis Using Excel 2016
Sandeep Kumar ­
4.7 (3,111)
Highest Rated

More Data Analysis Courses

Data Analysis students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy for Business.

Request a demo

Courses by Boris Paskhaver

Data Analysis with Pandas and Python
Boris Paskhaver
4.7 (14,802)
Bestseller
Learn to Code with Ruby
Boris Paskhaver
4.7 (4,391)
Bestseller
Learn to Code with Python
Boris Paskhaver
4.6 (3,712)
Testing Ruby with RSpec: The Complete Guide
Boris Paskhaver
4.7 (1,032)
Bestseller
Getting Started with React Hooks
Boris Paskhaver
4.6 (353)

Courses by Boris Paskhaver