Jupyter Notebook Keyboard Shortcuts
Jupyter's shortcut system is genuinely unlike most editors because it's modal, borrowing a concept familiar to Vim users: Command mode (cell selected but not being typed into, indicated by a blue left border) uses single unmodified letters as shortcuts, while Edit mode (actively typing inside a cell, green border) requires modifier keys since letters need to type normally. This split confuses newcomers constantly — pressing 'A' expecting to type the letter but instead inserting a new cell above is a rite of passage for anyone new to notebooks. Once internalized, though, it's a genuinely fast system, particularly for the cell-reordering and cell-type-switching operations that would otherwise require menu clicks. These shortcuts are consistent across Windows, Mac, and Linux since it runs entirely in the browser, aside from the standard Ctrl/Cmd modifier swap. Merging and multi-selecting cells matter most during the messier, exploratory phase of notebook-based work, when a train of thought originally split across several small cells often benefits from being consolidated into fewer, cleaner cells once the exploration settles into something worth keeping.
Command Mode
| Action | Windows | Mac | Description |
|---|---|---|---|
| Insert cell above | A (Command mode) | A | Inserts a new empty cell directly above the currently selected one, only functional in Command mode — pressing A while actively editing text inside a cell just types the letter A instead. |
| Insert cell below | B (Command mode) | B | Inserts a new empty cell directly below the currently selected one, the far more commonly used of the two insert directions since most workflows build downward. |
| Delete selected cell | D, D (press twice) | D, D | Deletes the currently selected cell, requiring the D key pressed twice in quick succession as a deliberate guard against accidental single-keystroke deletion of cell content. |
| Convert cell to Markdown | M (Command mode) | M | Changes the currently selected cell's type from code to Markdown, letting it render formatted text, headings, and links instead of being executed as code. |
| Convert cell to Code | Y (Command mode) | Y | Changes the currently selected cell's type back to Code, the reverse of converting to Markdown. |
| Copy selected cell | C (Command mode) | C | Copies the entire selected cell (code and output) to Jupyter's internal clipboard, separate from the OS clipboard, for pasting elsewhere in the notebook with V. |
| Extend cell selection up/down | Shift+J / Shift+K (Command mode) | Shift+J / Shift+K | Extends the current cell selection to include the next or previous cell as well, letting you select several adjacent cells at once for a bulk action like deleting or moving them together. |
| Merge selected cells | Shift+M (Command mode) | Shift+M | Combines the currently selected cells (extended via Shift+J/K) into a single cell, concatenating their content, useful for consolidating what was originally split across several small cells during exploratory work. |
| Undo last cell operation | Z (Command mode) | Z | Undoes the most recent cell-level operation (like an accidental delete), distinct from Ctrl+Z inside Edit mode which undoes text-editing changes within a cell rather than structural cell operations. |
Edit Mode
| Action | Windows | Mac | Description |
|---|---|---|---|
| Enter Edit mode | Enter (Command mode) | Return | Switches from Command mode into Edit mode on the selected cell, placing a text cursor inside it and changing the border color from blue to green as a visual indicator of the mode switch. |
| Exit Edit mode | Esc | Esc | Returns from Edit mode back to Command mode without executing the cell, the key most new users reach for reflexively once they understand the modal system exists. |
| Open Find and Replace | F (Command mode) | F | Opens a find-and-replace dialog scoped to the current notebook, letting you search across cell content for a specific string and optionally replace it, useful for renaming a variable used across many cells. |
Cell Execution
| Action | Windows | Mac | Description |
|---|---|---|---|
| Run cell, select next | Shift+Enter | Shift+Return | Executes the current cell's code and moves selection to the next cell (creating a new one if it's the last cell in the notebook), the most commonly used execution shortcut for working through a notebook sequentially. |
| Run cell, insert below | Alt+Enter | Option+Return | Executes the current cell and immediately inserts a new empty cell directly below it, useful when iterating and you know you'll want another cell right after this one regardless of what currently follows. |
| Run cell, stay selected | Ctrl+Enter | Cmd+Return | Executes the current cell but keeps that same cell selected afterward rather than advancing, useful for repeatedly re-running one cell (like a plotting cell) while tweaking its code between runs. |
Frequently Asked Questions
Why does pressing D once do nothing, but pressing it twice deletes the cell?
Delete Cell is deliberately bound to a double-tap (D, D in quick succession) rather than a single keystroke, specifically as a safeguard against accidentally deleting a cell's content with one stray keypress while in Command mode. A single D press does nothing by itself and waits briefly for a second D before triggering the delete.
How do I tell whether I'm in Command mode or Edit mode without testing a shortcut?
Jupyter shows this visually with the selected cell's left border color — a blue border means Command mode (single letters act as shortcuts), while a green border means Edit mode (you're typing directly into the cell and need modifier-key shortcuts). Glancing at that border color before pressing a single-letter shortcut avoids the common mistake of accidentally typing a letter into your code instead of triggering the intended action.
What's the actual difference between the three 'run cell' shortcuts?
All three execute the current cell's code identically — they differ only in what happens to selection afterward. Shift+Enter moves to (or creates) the next cell, Alt+Enter always inserts and selects a brand new cell directly below regardless of what already follows, and Ctrl+Enter (Cmd+Return on Mac) keeps the same cell selected, which is the one to use when you're iterating repeatedly on a single cell like a data visualization.
Why does pressing a letter key sometimes run a command instead of typing into a cell?
Jupyter notebooks have two distinct input modes just like Vim does: Command mode (blue cell border) treats letter keys as commands — pressing a converts the current cell to Markdown, b inserts a cell below, dd deletes the selected cell — while Edit mode (green cell border, entered by pressing Enter or clicking into a cell) treats the same keys as literal typed text. Forgetting which mode you're in is the single most common source of confusion for people new to notebooks, since pressing dd in Edit mode just types the letter d twice into your code rather than deleting anything.
Is there a way to restart the kernel and rerun every cell from the top in one action?
The Kernel menu's 'Restart & Run All' option does exactly this, clearing all variables and outputs, restarting the Python (or other language) process fresh, and then executing every cell in order from top to bottom — the standard sanity check before considering a notebook finished, since it catches any cell that only worked because of leftover state from a cell you ran out of order earlier, a common way notebooks silently develop hidden execution-order dependencies that are invisible until you actually restart clean. Making this a habit before sharing or submitting a notebook helps catch that class of bug before someone else runs into it first.
What's the difference between Z in Command mode and Ctrl+Z while typing in a cell?
Z pressed in Command mode undoes structural cell-level operations, like restoring a cell you just deleted, while Ctrl+Z (or Cmd+Z) used inside Edit mode while actively typing undoes ordinary text-editing changes within that specific cell's content — they operate on two different undo histories, one for cell structure and one for text content.