How do you delete a cell in Google Colab?

Google Colab · Cell Management · updated 2026-08-23

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

ShortcutActionNotes
Ctrl + M + BAdd Code Cell BelowInsert code cell below current
Ctrl + M + AAdd Code Cell AboveInsert code cell above current
Ctrl + M + DDelete CellDelete current cell
Ctrl + M + YConvert to CodeConvert cell to code cell
Ctrl + M + MConvert to TextConvert cell to text cell
Ctrl + M + Up/DownMove CellMove 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.