Notebooks
A Jupyter notebook opens as it reads in Jupyter: each cell ruled off, Markdown laid out, code colored, and what running it left — printed text, plots, errors — under the cell that made it. Nothing here runs it.
What the keys do
| Key | For a notebook |
|---|---|
| Enter | Hands it to the application macOS opens notebooks with |
| F3 | Shows the notebook, as above |
| ⇧F3 | Shows the file as it is, which is JSON, in the text viewer |
| F4 | Opens the JSON in the built-in editor |
Opening files says how to change them.
Recognized by
The extension .ipynb. Notebooks in format 4, and the older format 3, are read.
At a glance
| Key | Action |
|---|---|
| F2 | Next cell |
| ⇧F2 | Previous cell |
| F7 | Search… |
| F3 | Find next |
| ⇧F3 | Find the one before |
| F4 | As text |
| ⇧F9 | All it says about itself |
Reading it
↑ and ↓ move a line, Page Up and Page Down a screen, Home and End to the start and the end; the wheel scrolls. F2 and ⇧F2 go to the start of the next cell and the one before.
- Cells
- Each starts with a rule naming it — Markdown, Raw, or In [3] for code, with the number of the run that last ran it, blank if it never ran.
- Markdown cells
- Laid out as a Markdown document is.
- Code cells
- In a bar, colored in the notebook’s own language, which it names after its cells — so the colors come a moment after the text, and nothing moves when they do. A long line wraps, since there is no scrolling sideways.
- Printed text
- As it was printed. Text sent to the error stream is behind a red bar.
- Errors
- Behind a red bar, the traceback in the colors the terminal gave it.
- Pictures
- PNG, JPEG and SVG, placed in the page and scrolling with it, never taller than the window. A picture the notebook asks to be shown smaller than its pixels, as a sharp plot is, is shown at that size.
- Results
- Marked Out [3]. A result that is only HTML is shown as its source, marked HTML.
- Anything else
- Named by its kind, such as
[text/latex].
A large notebook shows its first cells while the rest is read.
Finding in it
F7 asks what to look for, with Match case and Regular expression, and Find next or Find previous. It looks through the notebook as it is shown — cells and their outputs — and comes round at the end. F3 and ⇧F3 look again.
It says Searching… while it looks, and the window stays free. A pattern that takes too long is given up on, and it says The pattern took too long.
What the panel lists
⇧F9 lists:
- Notebook
- The kernel, the language and its version, the format, and the file’s name.
- Cells
- How many of each kind, and how many have been run.
- Outputs
- How many, and how many of them are pictures and errors.
- Problems
- What in the file is not what a notebook should be, numbered.
When it is not quite a notebook
- A file that is not JSON at all opens in the text viewer.
- JSON that is not shaped like a notebook shows whatever of it reads as cells, and the panel lists the problems. With nothing that reads as cells, the view says so.
- At most 50,000 cells, 32 million characters of text and 256 MB of pictures are held. Past any of them, a line at the end says how many cells are shown and which limit stopped it, and F4 shows the whole file.
Editing it
F4 opens the notebook’s JSON in the built-in editor, where it is not colored: choose JSON with
Language…, in the View menu, and tick the box to keep it for every .ipynb file. There
is no way to change a cell as a cell.
Limits
- Cells cannot be run, and nothing here talks to a kernel.
- Cells do not fold away.
- HTML output is not drawn, and interactive output — widgets, scripts — is named only.