Skip to content

Code Blocks#

FoldNotes supports fenced code blocks for displaying code, configuration files, or any preformatted text.

Syntax#

Wrap code in triple backticks. Optionally specify a language for syntax highlighting in the preview:

```python
def hello():
    print("Hello, world!")
```

Editor Behaviour#

Code blocks in the editor:

  • Use a monospace font for all content between the fences
  • Show a subtle background highlight to visually group the block
  • Disable spell checking inside the block
  • Preserve indentation exactly as typed (no auto-indent or list continuation)
  • Support folding — click the fold arrow on the opening fence to collapse the entire block

This calm, literal editing applies once the block is closed — see below.

Opening and Closing a Block#

A code block needs both an opening and a closing fence (a line of triple backticks). The lines between a matched pair are what FoldNotes treats as code.

The quickest ways to get a correct pair:

  • Type a triple-backtick fence on its own line — FoldNotes adds the closing fence for you and drops your cursor on the blank line between them, ready to type. You can add a language after the opening fence for preview highlighting (for example python or swift).
  • Or use the toolbar's Insert Code Block button, which wraps the current selection (or an empty block) in a matched pair.

Inside a closed block, editing is literal:

  • Tab inserts a real tab character — it does not indent or outdent the line
  • Return inserts a plain newline — no list or quote continuation
  • Text is inserted exactly as typed, with no Markdown auto-formatting

If Editing Feels Wrong#

Inside a properly closed, balanced code block, editing is literal — Tab inserts a tab, Return a plain newline, no auto-formatting. If instead it behaves like the normal Markdown editor — Tab indents the line, Return continues a list or snaps to the start of the line, typing formats unexpectedly — then the block isn't being recognised as a closed pair, and FoldNotes is treating your code as ordinary text.

FoldNotes pairs fences top to bottom across the whole note, so the usual causes are:

  • No closing fence. The block is still open. An opening fence with no partner is drawn dimmed — that's your signal to add a closing fence.
  • An odd number of fences in the note. One extra or missing fence anywhere unbalances every block below it. Make sure the note has an even number of fences.
  • Code that contains a triple-backtick line. Those backticks close the block early — a limitation of the fenced-code format itself.
  • A pasted fence. Auto-closing happens only when you type the fence; pasting a fence line doesn't add a partner.

The fix is the same in every case: make sure each fence has a partner (an even number in the note). As soon as the fences balance, the block switches straight back to literal editing.

Pasting into Code Blocks#

When you paste text inside a code block, FoldNotes inserts it as plain text — no Markdown conversion is applied. This preserves code indentation and prevents formatting interference.

Inline Code#

For short code snippets within a paragraph, use single backticks:

Use the `fn daily append` command to add text.

This renders in a monospace font with a subtle background.

Syntax Highlighting#

Syntax highlighting is available in the Preview window (Cmd+Shift+P) via Highlight.js. Specify the language after the opening fence:

```swift
let greeting = "Hello"
print(greeting)
```

The editor itself uses monospace styling for all code block content regardless of language.

Drag and Drop#

Code blocks can be dragged as a unit. Grab the drag handle on the opening fence line to move the entire block (including content and closing fence) to a new position. See Drag & Drop for more on moving content around your note.