Logo User Guide

Code

Trilium supports creating "code" notes, i.e. notes which contain some sort of formal code - be it programming language (C++, JavaScript), structured data (JSON, XML) or other types of codes (CSS etc.).

This can be useful for a few things:

  • computer programmers can store code snippets as notes with syntax highlighting
  • JavaScript code notes can be executed inside Trilium for some extra functionality
    • we call such JavaScript code notes "scripts" - see Scripting
  • JSON, XML etc. can be used as storage for structured data (typically used in conjunction with scripting)

For shorter snippets of code that can be embedded in Text notes, see Code blocks.

Article Image

Adjusting the language of a code note#

In the Ribbon, look for the Note type selector and click it to reveal the possible note types. Inside of it there will be a section called Code, select any one of the languages.

Article Image

Adjusting the list of languages#

Trilium supports syntax highlighting for many languages, but by default displays only some of them. The supported languages can be adjusted by going to Options, then Code Notes and looking for the Available MIME types in the dropdown section. Simply check any of the items to add them to the list, or un-check them to remove them from the list.

Note that the list of languages is not immediately refreshed, you'd have to manually refresh the application.

The list of languages is also shared with the Code blocks feature of Text notes.

Color schemes#

Since Trilium 0.94.0 the colors of code notes can be customized by going Options → Code Notes and looking for the Appearance section.