Skip to content

Cell operations

All of these work in notebook mode.

Key Does
a New code cell after the selected one
b New code cell before the selected one
dd Delete the selected cell
yy Copy the selected cell
p P Paste the last deleted or copied cells after / before the selected one

yy also puts the cell’s source on the system clipboard (through the terminal’s OSC 52 support), so you can paste it into another program.

J and K move the selected cell down and up.

V starts a selection, like vim’s visual line mode: j, k, gg, G and the other motions extend it, and the status line shows V-LINE. Then press one key to act on every selected cell:

Key Does
d or x Delete them (p pastes them back, in order)
y Copy them; their sources go to the clipboard too
J K Move them down / up as a block; the selection stays, so you can keep moving
r, Space or Enter Run them, top to bottom
c Clear their outputs
f Format them
M Merge them into one cell

Esc or V ends the selection; so does any other key, which then does its usual thing. Each of these is a single step for u to undo.

  • Ctrl+\ while editing splits the cell at the cursor into two cells.
  • M merges the selected cell with the one below it.

u undoes the last cell operation: adding, deleting, pasting, moving, splitting, merging, changing a cell’s type, clearing outputs. Ctrl+r redoes. Any new operation clears the redo history.

This is separate from undo inside a cell, which is part of the editor.