Skip to content
Superliner

Code blocks

A code block is a note whose text is code. Its line breaks are kept, the text is set in a monospaced face and coloured by language. It is still a note, so it can have children, fields, a supertag and its own page.

Make or remove
Format ▸ Code Block, ⌥⌘C
Language
Format ▸ Code Language…, or the language label on the block
Typed
three backticks, a language name, then Space
Languages
17 are coloured, plus Plain text
Markdown copy
a fenced block that names the language

Make a code block

Put the caret in a note, or select it, and press ⌥⌘C. The note keeps its text and becomes a code block in Plain text. Press the same keys again, or choose Format ▸ Code Block again, to turn it back into an ordinary note.

⌥⌘CThe text stays where it is. Only its face and its language change.
  1. Start from any note

    Put the caret in the note, or select it. The note can have children and fields.

  2. Make the block

    Press ⌥⌘C or choose Format ▸ Code Block. A note with a heading cannot become a code block, so remove the heading first.

  3. Pick the language

    Choose Format ▸ Code Language…, or click the language label on the block, and type part of a name. Choose a language to set it.

Choose a language

The language picker is headed “Find a language” and lists every language. Type to narrow it. Each language matches on its name, its identifier and the short names in the table below, so typing “py” finds Python. The language in use has a checkmark. Choosing a language on a note that is not a code block makes it one.

Type a short name or part of a name. Return picks the highlighted language.
LanguageAlso found by typing
Plain texttext, txt, plaintext (not coloured)
Bashsh, shell, zsh
Ch
C++c++, cc, cxx, hpp
CSSnone
Gogolang
HTMLhtm
Javanone
JavaScriptjs, node, mjs
JSONnone
Markdownmd
Pythonpy
Rubyrb
Rustrs
SQLnone
Swiftnone
TypeScriptts
YAMLyml

The 17 coloured languages are every row except Plain text.

Type in a code block

Typing works as it does in any note. The keys below change only what a code block needs: Return, Tab and Backspace.

Return
Starts a new line inside the block. On an empty last line it ends the block and starts a note below it.
Tab
Inserts two spaces. With several lines selected, indents each of them.
Shift-Tab
Removes a tab or up to two spaces from the start of each selected line.
Backspace
At the very start of the block, turns it back into an ordinary note. The text stays.
⌘Return
Adds a checkbox to the note, or checks and unchecks it. It works in a code block as well.
Esc
Selects the note as a block, as it does for any note.

Start a code block by typing

Type three backticks and a language name, such as swift, as the whole text of a note. Then press Space or Return. The fence text goes and the note becomes a code block in that language. One Undo brings the fence text back. A name Superliner does not know makes the block Plain text.

SpaceThe fence goes; the block keeps the language.

Copy the code

A code block has a Copy button. It copies the code as plain text, without colours, marks or links, and the button reads Copied for a moment.

Copy takes the code as plain text.

Combine it

Limits

  • A note longer than 45,000 characters, or with more than 1,000 lines, is shown in the code face but not coloured. Its language label says “Too long to colour”.
  • A language saved by a newer build shows its name as stored and draws as plain text.
  • A note with a heading cannot become a code block.
  • Links inside a code block are not clickable.