NotaBene User Guide ENCS Join the beta

Code blocks

Keep code in a note as code — monospaced, colored by language, and copied out exactly as written.

Make a code block

The code sits in a rounded grey box that runs the full width of the column, with space above and below it. To write code inside a sentence instead, type it between backticks.

Choose the language

In the box's top-right corner is the language the code is written in. Choose it from the menu there: Automatic, Plain Text, HTML, JavaScript, PHP, Python, Swift, JSON, CSS, Shell or SQL.

Left on Automatic, the block recognizes the language by itself, and the corner shows the guess in brackets — (Python) — while a language you chose is shown without them. When the code says too little, or two languages fit equally well, it stays Automatic rather than guessing. A language you choose is never overridden, and it is kept with the note.

The code is colored the way Xcode colors it — keywords, strings, numbers, comments and names — in light and dark appearance and on every device. The colors are only for reading: they are not copied, exported as Markdown or sent to your other devices. A printed note and a PDF keep them.

Copy the code

Click or tap the copy button in the box's top-right corner. It copies just the characters — no font, no indent — so they paste into Xcode or a terminal as code.

Leave a code block

Return inside a block starts another line of code — press it twice for an empty line, as in a callout. To write below the block, tap or click under it: a block at the end of a note always has a plain line beneath it to write on.

To turn the block back into ordinary text, do one of these:

Code blocks in Markdown

In Markdown, a code block is written as a fenced block — three backticks followed by its language, such as swift — and a fenced block that comes in is read back as a code block in that language.

See Also: Insert anything with / · Write and format · Your data: export and print