Running code
Cells run on the notebook’s kernel. Output streams in live as the kernel produces it.
Running cells
Section titled “Running cells”| Key | Does |
|---|---|
| Shift+Enter or r | Run the cell and select the next one |
| Ctrl+Enter or Space | Run the cell and stay on it |
| X | Run all cells |
| < | Run all cells above the selected one |
| > | Run the selected cell and all cells below |
Shift+Enter and Ctrl+Enter need a terminal with the kitty keyboard protocol; r and Space work everywhere. See Terminal setup.
The gutter
Section titled “The gutter”Each code cell’s header shows its state:
In [ ]: not run yet.In [·]: queued, waiting for the cells before it.In [*]: running now.In [3]: the execution count. After a run in this session, the header also shows how long it took.
When you run several cells with X, < or >, the selection follows the cell that is running, so you watch the notebook execute. Move the selection yourself and it stops following.
Cells you run while the kernel is still starting are queued and run as soon as it’s ready.
Interrupting and restarting
Section titled “Interrupting and restarting”Ctrl+c interrupts the kernel, like the stop button in JupyterLab: the running cell ends with a KeyboardInterrupt.
When a cell fails, whether from an interrupt or an exception, the kernel skips the cells queued behind it, as in JupyterLab. A run-all therefore stops at the first error.
R restarts the kernel, which clears all variables. jOtter asks first:
- R restarts.
- a restarts and then runs all cells.
- Any other key cancels.
If the kernel dies (for example, out of memory), the status line says so and R starts a new one.
input()
Section titled “input()”When code calls input(), a box with the prompt opens over the notebook. Type your answer and press Enter; Esc sends an empty answer, and Ctrl+c interrupts the kernel instead. getpass() works too: what you type is shown as dots.
Status line
Section titled “Status line”The status line at the bottom shows, from left to right:
- The mode:
VIEWin notebook mode;NORMAL,INSERT,VISUALand so on while editing a cell. - The file name, with
[+]when there are unsaved changes. - The selected cell’s position, like
cell 3/12. - The kernel’s state:
○ idle,● busyor◌ no kernel. - Messages, questions such as the quit prompt, and what you type for search or save-as.