Jupyter Notebook and Jupyter Lab are essential tools for data scientists and developers. Using shortcuts in these environments can significantly boost productivity, so I’ve compiled a list of shortcuts to share. Use these shortcuts to work faster and more efficiently.
Frequently Used Shortcuts
Shortcut | Description | Mode |
---|---|---|
Shift + Enter | Run cell and move to the next cell | All Modes |
Ctrl + Enter | Run cell and stay in the same cell | All Modes |
Alt + Enter | Run cell and insert a new cell below | All Modes |
Esc | Switch to command mode | Edit Mode |
Enter | Switch to edit mode | Command Mode |
A | Insert cell above | Command Mode |
B | Insert cell below | Command Mode |
D, D | Delete cell | Command Mode |
M | Convert cell to Markdown | Command Mode |
Y | Convert cell to code | Command Mode |
C | Copy cell | Command Mode |
V | Paste cell | Command Mode |
Z | Undo cell delete | Command Mode |
Shift + M | Merge cells | Command Mode |
Ctrl + S | Save file | All Modes |
Ctrl + Shift + – | Split cell at cursor | Edit Mode |
Note: The “Ctrl + Shift + -” shortcut for splitting cells also zooms out the screen in Chrome. If you’re using Chrome, you might need to change the shortcut settings in Chrome or Jupyter.
Modes
When working in Jupyter Notebook and Jupyter Lab, there are two main modes: Edit Mode and Command Mode. Each mode has its own set of shortcuts designed for specific tasks.
Edit Mode
Edit mode is used for editing the content of a cell. You can write code or enter text in this mode. In edit mode, the cell has a colored border, and the cursor is visible inside the cell.
Command Mode
Command mode is used for managing entire cells. You can add, delete, move cells, and change their types in this mode. When in command mode, the cell’s contents are not active.
Jupyter Notebook Shortcuts
Jupyter Notebook combines code execution and documentation, making it a powerful tool for managing data science projects. Here are some commonly used shortcuts in Jupyter Notebook.
Edit Mode
- Esc: Switch to command mode
- Ctrl + Shift + –: Split cell at cursor
- Tab: Autocomplete code
Command Mode
- Enter: Switch to edit mode
- Shift + Enter: Run cell and move to the next cell
- Ctrl + Enter: Run cell and stay in the same cell
- Alt + Enter: Run cell and insert a new cell below
- A: Insert cell above
- B: Insert cell below
- D, D: Delete cell
- M: Convert cell to Markdown
- Y: Convert cell to code
- C: Copy cell
- V: Paste cell
- Z: Undo cell delete
- Shift + M: Merge cells
Jupyter Lab Shortcuts
Jupyter Lab is an extended version of Jupyter Notebook with more powerful features. It supports all the shortcuts available in Jupyter Notebook and includes a few additional useful shortcuts.
Edit Mode
- Ctrl + Shift + P: Open command palette
- Ctrl + Shift + –: Split cell at cursor
- Tab: Autocomplete code
- Ctrl + ]: Increase indent
- Ctrl + [: Decrease indent
Command Mode
- Enter: Switch to edit mode
- Shift + Enter: Run cell and move to the next cell
- Ctrl + Enter: Run cell and stay in the same cell
- Alt + Enter: Run cell and insert a new cell below
- A: Insert cell above
- B: Insert cell below
- D, D: Delete cell
- M: Convert cell to Markdown
- Y: Convert cell to code
- C: Copy cell
- V: Paste cell
- Z: Undo cell delete
- Shift + M: Merge cells
- Ctrl + Shift + P: Open command palette
- F: Find and replace within cells
- Ctrl + Shift + L: Select all matching text
Understanding and using these shortcuts in both modes will make your work in Jupyter Notebook and Jupyter Lab much more efficient. Mastering these shortcuts can significantly enhance your productivity.