How do you delete a cell in Google Colab?
Ctrl + M + D — Delete Cell
Press Ctrl + M and then D (a two-key sequence: release Ctrl + M first) to delete the current cell in Google Colab. Ctrl + M followed by Z undoes the deletion.
Colab's cell shortcuts only fire in command mode - press Esc first if the cursor is blinking inside the cell, otherwise the keys type into your code. The two-key sequence is a deliberate guard against deleting on a stray keystroke.
Deleted the wrong cell? Ctrl + M Z undoes the last cell operation. The same command-mode family covers most structural edits: A inserts a cell above, B below, and M / Y convert between text and code cells.
Related Google Colab shortcuts: Cell Management
| Shortcut | Action | Notes |
|---|---|---|
| Ctrl + M + B | Add Code Cell Below | Insert code cell below current |
| Ctrl + M + A | Add Code Cell Above | Insert code cell above current |
| Ctrl + M + D | Delete Cell | Delete current cell |
| Ctrl + M + Y | Convert to Code | Convert cell to code cell |
| Ctrl + M + M | Convert to Text | Convert cell to text cell |
| Ctrl + M + Up/Down | Move Cell | Move cell up or down |
From the Google Colab reference (15 entries) · all how-to answers
The two-key sequence
Colab uses Ctrl + M as a prefix because the browser owns most Ctrl + letter shortcuts: press Ctrl + M, let go, then press D. The cell must be selected (its left border highlighted) rather than in edit mode — if the cursor is inside the code, press Esc first or click the cell margin, otherwise the D is typed into the cell. The same prefix gives Ctrl + M then A and B for inserting cells above and below, and Ctrl + M then Z to undo the deletion.
Deleting several cells
Shift + click or Shift + Up/Down extends the selection across cells, and one Ctrl + M, D removes them all. The cell toolbar's trash icon and the Edit menu do the same with the mouse. Deleted cells with output are gone from the notebook, but the runtime keeps any variables they defined until it is restarted.
Changing the prefix
Tools › Keyboard shortcuts lets you rebind any command, and many people set delete-cell to a single key or to the Jupyter-style D, D. The change is saved to your Google account, so it follows you between notebooks and machines.