> 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.

# 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:

```python
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

| Setting                  | Effect                                                   |
| ------------------------ | -------------------------------------------------------- |
| **Programming Language** | Selects syntax highlighting; **Plain Text** is available |
| **Show Language Header** | Shows the language above the code                        |
| **Show Line Numbers**    | Displays line numbers beside the code                    |
| **Wrap Lines**           | Controls whether long lines wrap                         |
| **Dark Mode Editor**     | Uses 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](https://docs.flashnerd.com/reference/fields/cloze.md) when the task is to recall a missing text fragment. Code syntax highlighting alone does not hide answers.

Related: [Field settings](https://docs.flashnerd.com/guide/cards/field-settings.md).
