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

The editor in a cell is vim. This page lists the vim keys that gpython has. The keys for cells are on the Keys page.

To turn the vim keys off, use :set novim or start with --no-vim.

Differences from vim

Subject In gpython
The file The notebook is one file. % is all lines of all cells. $ is the last line of the notebook
Line numbers A number without more is a line of the current cell, as the gutter shows
No range The command works on the cursor line. In cell mode, it works on the selected cell
Folds A fold is a full cell. There are no folds in a cell
Undo One history for the full notebook. u goes to the cell that changed
j / k at the edge of a cell The cursor goes to the next / previous cell
escape in normal mode Goes to cell mode
Not available d/pattern, q:, gn

A :%s needs one u for each cell that it changed.

Normal mode

Move

Key Action
h j k l Left, down, up, right
w b e ge Word forward, word back, word end, previous word end
W B E gE The same, with only spaces as separators
0 ^ $ g_ Line start, first non-blank, line end, last non-blank
gm g0 g$ Middle, start and end of the screen line
| _ + - Column n; first non-blank of this, the next, the previous line
gg / G / 3G First / last / third line of the cell
H M L Top, middle, bottom visible line
f F t T, ; , Find a character on the line; repeat, reverse
% Matching bracket
( ) / { } Previous, next sentence / empty line
[( [{ ]) ]} Unmatched bracket before / after the cursor
[[ ]] [m ]m Previous / next def or class
gd / gD First use of the word at the cursor in this cell
ctrl+n / ctrl+p Down / up a line

Go between cells and tabs

Key Action
j / k at the edge Next / previous cell
ctrl+↓ / ctrl+↑, alt+↓ / alt+↑ Next / previous cell
gt / gT / 2gt Next / previous / second tab
escape Cell mode

Insert

Key Action
i a I A Insert before, after the cursor; at the line start, line end
o / O New line below / above
gi / gI Insert where insert mode stopped last / at column 0
3i, 3a, 3o The typed text repeats three times
R Replace mode: type over text until escape. backspace puts the old text back

Change text

Key Action
x X s S Delete a character forward, back; change a character, a line
dd D cc C Delete the line, to the line end; change the line, to the line end
d, c, y + motion or object Delete, change, copy: dw, d$, dj, cw, di", dap, yi(
yy, Y, 3yy Copy lines
p / P / 2p Paste after / before the cursor
gp / gP Paste and put the cursor after the text
r<char> / 3rx / r<enter> Replace one character / three / divide the line
J / gJ / 3J Join lines with / without a space; join three lines
~ / g~ / gu / gU Change case: one character; swap, lower, upper for a motion, object or line
>> / << / >j / >ip Add / remove an indent on a line or the lines of a motion
== / =ip / gg=G Correct the indent to the 4-space levels of Python
gq / gw Wrap lines at 79 columns. Comments keep their #. gw keeps the cursor
g? rot13
ctrl+a / ctrl+x Add to / subtract from the number at or after the cursor. 5 ctrl+a adds 5
. Repeat the last change. 3. repeats with a count
u / ctrl+r Undo / redo
U Undo the latest changes to the line

To delete the cell, press escape, then dd.

Text objects

iw aw iW aW ip ap is as i" a" i' a' i( a( i[ a[ i{ a{ i<

A count on a bracket object selects the pair around it: d2i(.

Registers, marks and macros

Key Action
"ayy / "ap Use register a for a copy, delete or paste. "A adds to it. "_ discards
"0, "1–"9, "- Last copy; the last nine deleted lines; the last small delete
"., "+ The last inserted text; the system clipboard
ma / `a / 'a Set mark a / go to its character / go to its line
qa … q Record keys into macro a
@a / 3@a / @@ Play macro a / three times / play the last macro again

Text that you copy also goes to the system clipboard.

Search

Key Action
/text Next match after the cursor, in all cells. A capital letter makes the search match case
/3 Go to cell 3
?text Search backward. n then also goes backward
n / N / 3n Next / previous match; go three matches forward
* / # / g* / g# Search forward / backward for the word at the cursor
:noh Remove the highlight. n shows it again

Scroll and jump

Key Action
ctrl+d / ctrl+u Half a page down / up
ctrl+f A page down
ctrl+e / ctrl+y One line down / up
zz / zt / zb Put the cursor line in the middle / at the top / at the bottom. Also z., z<enter>, z-
ctrl+o / tab Jump list: back / forward
'', `` Back to the start of the last jump
g; / g, Older / newer place where the text changed

ctrl+b is not page up. It shows or hides the file explorer.

Folds

Key Action Command
zc Hide the code of this cell :foldclose
za Show or hide the code of this cell
zM Hide the code of all cells :foldclose all
zR Show the code of all cells :foldopen all

Run and get help

Key Action
space r … Run cells. See The r keys
space f f Find a file by name
K Show the help of the kernel for the name at the cursor, as name? does
ga / ctrl+g Show the character code / the line and column
ZZ / ZQ Save and close the window / close and do not save
@: Do the last : command again
: Type a command

Visual mode

Start with v (characters), V (lines) or ctrl+v (block). gv selects the last area again.

Key Action
Motions and text objects Extend the selection
o Go to the other end of the selection
y / Y Copy the selection / its lines
d x / X D Delete the selection / its lines
c s / C S R Change the selection / its lines
p / P Replace the selection with the copied text
> / < / = Add, remove, correct the indent
J / gJ Join the lines
~ / u / U Swap case / lower case / upper case
r<char> Replace each selected character
gq / g? Wrap at 79 columns / rot13
ctrl+a / ctrl+x Add to / subtract from the first number on each line
g ctrl+a Add 1, 2, 3 … on the lines
: Command on the selected lines ('<,'>)
v / V / ctrl+v Change the type of selection
escape Go out of visual mode

Block selection

Key Action
I / A / c Insert before / add after / change the block on each line. Type on the first line, then press escape
$ Extend to the end of each line
d y p ~ u U r Delete, copy, paste over, change case, replace characters
O Go to the other corner

Insert mode

Key Action
ctrl+w / ctrl+u Delete the word before the cursor / all text before it on the line
ctrl+t / ctrl+d Add / remove an indent
ctrl+r x Paste register x. ctrl+r " pastes the unnamed register
ctrl+a Insert the last inserted text again
ctrl+e / ctrl+y Copy the character below / above the cursor
ctrl+n / ctrl+p Complete a name
ctrl+v Insert the next key as it is. ctrl+v tab inserts a real tab
ctrl+k + two characters Type a digraph: ctrl+k a : gives ä, ctrl+k - > gives →. :digraphs lists them
ctrl+o Do one normal-mode command, then come back
ctrl+h Backspace

Completion

The kernel supplies the completions. Thus completion works only when the kernel is ready.

Event Result
You type a name or a . A popup shows the matches after a short pause. The text does not change
tab gpython inserts the common start of the matches and shows the others
ctrl+n / ctrl+p Move down / up in the popup

Line commands

Ranges

Range Lines
none The cursor line. In cell mode: the selected cell
N or N,M Lines of the current cell
. The cursor line
$ The last line of the notebook
% All lines of all cells
.,$ From the cursor to the end of the notebook
'<,'> The visual selection

Replace

:s/pattern/new/flags

Part What you can use
Pattern Vim patterns: \( \) \< \> |
New text &, \1, \u, \U, \r
Flags g i I n &
& Do the last replacement again on this line
g& Do it again in all cells
:&& Do it again with the same flags

Commands on lines

Command Action
:g/pat/cmd Run cmd on each line that matches. cmd is d, s, j, >, <, m, t or normal
:v/pat/cmd, :g!/pat/cmd The same, on each line that does not match
:g/pat/ List the matching lines
:d Delete lines. In cell mode, :d deletes the cell
:j Join lines
:m0 Move lines
:t$, :co Copy lines
:2,4> / :2,4< Add / remove an indent
:normal A; Run normal-mode keys on each line

In a notebook with more than 100 cells, :normal works only on cells that are built on the screen.

What changed for vim

Earlier versions used some of these keys for the application. Now the vim meaning applies in the editor.

Key In the editor now Earlier Where the earlier action is
r Replace a character Run keys r … in cell mode; space r … in the editor
J Join lines Next cell j after the last line, ctrl+↓, alt+↓. In cell mode J moves the cell
K Help for the name at the cursor Previous cell k before the first line, ctrl+↑, alt+↑
gJ Join without spaces Join with a space J
:d Delete lines Delete the cell :d or dd in cell mode
ctrl+d Half page down. Insert: remove indent Delete the cell ctrl+d or dd in cell mode, :delete
ctrl+e Scroll a line. Insert: copy the character below Run the cell ctrl+enter, shift+enter, alt+enter, 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 command Outline ctrl+o in cell mode, :outline
ctrl+v Visual block. Insert: literal key Variables panel ctrl+v in cell mode, :vars
ctrl+k (insert) Digraph Stop the code ctrl+k in other modes, space r i, :interrupt
ctrl+w (insert) Delete the word before the cursor Window keys escape, then ctrl+w
ctrl+t (insert) Add an indent Theme picker Outside insert mode, :theme
? Search backward No action In cell mode ? is help
ctrl+f, ctrl+u, ctrl+y, tab Page down, half page up, scroll up, jump forward No action —
Cursor A block in the color of the mode A bar in insert mode :set cursor=bar

Clone this wiki locally