For AI agents: the complete documentation index is available at https://docs.flashnerd.com/llms.txt, the full documentation bundle is available at https://docs.flashnerd.com/llms-full.txt, and this page is available as Markdown at https://docs.flashnerd.com/reference/fields/code.md.
Skip to main content

Code

Use a Code field for syntax-highlighted examples, algorithms, and programming questions. It displays code; it does not execute the program.

Add a code example

  1. Add a Code field to the deck template and choose its side.
  2. Open its gear and set Programming Language.
  3. Enter the code in the card editor.
  4. Preview the card and save it.

For example, put this Python snippet on Front and 6 in a Text field on Back:

numbers = [1, 2, 3]
print(sum(numbers))

Add a Note field for the explanation: sum adds the values in the list. The answer is authored by you; Flashnerd does not run the snippet to verify it.

Display settings

SettingEffect
Programming LanguageSelects syntax highlighting; Plain Text is available
Show Language HeaderShows the language above the code
Show Line NumbersDisplays line numbers beside the code
Wrap LinesControls whether long lines wrap
Dark Mode EditorUses the dark code-editor appearance

Use template settings for a consistent deck, or a card-level override when one example uses a different language.

Keep code readable

Choose a short snippet that tests one idea. With wrapping off, a long line may require horizontal scrolling; with wrapping on, indentation can be harder to follow on narrow screens. Preview on a phone-sized card before adding many examples.

Use Cloze Deletion when the task is to recall a missing text fragment. Code syntax highlighting alone does not hide answers.

Related: Field settings.