Skip to content
igaurab edited this page Nov 18, 2026 · 2 revisions

The editor inside a cell is vim. The cell-level keys are on the Keys page.

Normal mode

Key Action
escape Leave the editor: cell mode
j / k Down / up a line; past the edge moves to the next cell (J / K move cells in cell mode)
J / gJ Join lines with / without a space (3J joins three)
r<char> / 3rx / r<enter> Replace the character under the cursor / three of them / split the line
space r 6 Run cell c6 (and space r r c C a A s k R i d t, as r … in cell mode)
gg / G / 3G First / last / third line of this cell
dd Delete line, like vim (3dd three lines; u undoes). To delete the cell: esc, then dd
. Repeat the last change (3. with a count)
~ / g~ / gu / gU Toggle / lower / upper case: ~ one character, gUiw g~w guu an object, motion or line
R Replace mode: overtype until escape (backspace restores)
>> / << / >j / >ip Indent / dedent the line, or the lines a motion or object covers
== / =ip / gg=G / V= Re-indent to Python's 4-space levels: nesting follows the shape of the lines, : opens a level, else/except and return close one
ma / `a / 'a Set mark a / jump to its character / its line (d`a and y'a work)
"ayy / "ap Named registers: "a before a yank, delete or put ("A appends, "_ discards)
qa … q / @a / @@ Record a macro into a, replay it (3@a), repeat the last replay
ctrl+a / ctrl+x Add to / subtract from the number under or after the cursor (5 ctrl+a)
ctrl+o (insert mode) One normal-mode command, then back to insert mode
/ Jump: /3 third cell (as numbered in the headers), /text next match after the cursor (smart case, highlighted)
? Search backward; n then goes backward too
n / N Next / previous match of the last search, across cells (3n skips three)
* / # / g* / g# Search forward / backward for the word under the cursor
:s/a/b/g / :%s / :.,$s / :'<,'>s / & / g& Substitute with vim patterns (\( \) \< \> |) and replacements (&, \1, \u, \U, \r), flags g i I n &; & repeats on this line, g& everywhere
:g/pat/cmd / :v/pat/cmd Run d s j > < m t normal on every (not) matching line; :g/pat/ lists the lines
:d :j :m0 :t$ :2,4> :normal A; vim line commands on a range (in cell mode :d deletes the cell)
K The kernel's help for the name under the cursor (like name?)
zc / za / zM / zR Folds are cells: hide this cell's code / every cell's code / show them all (H in cell mode)
ctrl+d / ctrl+u / ctrl+f / ctrl+b Scroll half a page / a page; the cursor moves along within the cell
ctrl+e / ctrl+y / zz zt zb Scroll one line / put the cursor line in the middle, top, bottom
ctrl+o / tab / '' Jump list back / forward; back to where the last jump started
g; / g, Older / newer change
gi / gI / gp / gP / U Insert where you left insert mode / at column 0; put leaving the cursor after; undo the line
gq / gw / g? Wrap at 79 columns (comments keep #) / rot13, with a motion, object or doubled
ctrl+v Visual block: I A c type on every line, $ to each line's end, d y p ~ u U r O
ZZ / ZQ / @: Save and close (:x) / close without saving / repeat the last ex command
gt / gT / 2gt Next / previous / second tab
: Ex command

Also h j k l w b e ge gE W B E 0 ^ $ g_ gm | _ + - H M L % ( ) { } [( [{ ]) ]} [[ ]] [m ]m gd, counts (3i repeats the insert), i a I A o O, x X s S dw d$ dj D cc cw C yy p P u ctrl+r, f F t T ; ,, text objects iw aw iW aW ip ap is as i" a" i' a' i( a( i[ i{ i< (d2i( takes the enclosing pair), registers "a "A "_ "0 "1-"9 "- ". "+, ga, ctrl+g, and visual mode v V ctrl+v with o O y d c p > < = J gJ ~ u U r gq g? ctrl+a ctrl+x g ctrl+a :. Ranges read the notebook as one file, like vim's buffer: % is every line of every cell, $ the notebook's last line, .,$ from here to the end of the notebook; no range is the cursor line (in cell mode: the selected cell); a plain number is that line of the current cell, as its gutter shows. Undo (u) and redo (ctrl+r) work on the whole notebook: u undoes the newest change, in any cell (it goes there), and also cell deletes, moves and adds. A :%s takes one u for each cell it changed.

Insert mode

ctrl+w ctrl+u delete a word / to the line start, ctrl+t ctrl+d indent / dedent, ctrl+r x puts register x, ctrl+a the last inserted text, ctrl+e ctrl+y copy the character below / above, ctrl+n ctrl+p complete, ctrl+v inserts the next key literally, ctrl+k and two characters types a digraph (ctrl+k a : ä, :digraphs), ctrl+o runs one normal command. Not there: d/pattern, folds inside a cell (folds are whole cells), q:, gn.

What changed for vim

Key In the editor now Before Where the old action lives
r vim replace (rx, 3rx, r<enter>) run prefix (r 6, r c, …) cell mode r …; space r … in the editor
J join lines next cell cell mode J moves the cell; j past the last line, ctrl+↓, alt+↓
K help for the name under the cursor previous cell k past the first line, ctrl+↑, alt+↑
ctrl+k (insert) digraph interrupt other modes ctrl+k, space r i, :interrupt
:d (editor) delete lines delete cell :d in cell mode, dd in cell mode
gJ join without spaces (as in vim) join with a space J
ctrl+d half page down; insert: dedent delete cell cell mode ctrl+d, dd, :delete
ctrl+e scroll a line; insert: copy the character below run cell ctrl+enter, shift+enter, alt+enter, cell mode ctrl+e, space r c
ctrl+n / ctrl+p line down / up; insert: complete new cell / palette cell mode, :new, o / O in cell mode
ctrl+o jump back; insert: one-shot command outline cell mode ctrl+o, :outline
ctrl+v visual block; insert: literal key variables panel cell mode ctrl+v, :vars
ctrl+f page down nothing
ctrl+w (insert) delete the word before the cursor window prefix escape, then ctrl+w
ctrl+t (insert) indent the line theme picker outside insert mode, :theme
ctrl+u / ctrl+y / tab half page up / scroll up / jump forward nothing —
? search backward nothing (cell mode: help) cell mode ? is still help
cursor block, coloured by mode bar in insert mode :set cursor=bar

Clone this wiki locally