# Editor tutorial

Build one flowchart in the Line9 editor, step by step.

## Before you start

In just a few minutes, you'll build this flowchart of a purchase request with the keyboard:

![The finished purchase request flowchart: a budget check with a Yes and a No outcome, a group, a comment and a Finance node.](/images/docs/screens/editor-tutorial/grouped.png)

The Line9 editor comes with [Line9 Pro](/docs/getting-started#line9-pro). Without a Pro account you can still follow along: when Line9 offers a preview, choose **Try it**. Nothing you make in the preview can be kept.

## Open the diagram and enter the editor

1. [Open the starting diagram](/docs/diagrams/tutorial-start.mmd). It has one node, Request.
2. Press **Enter**. The editor opens, and a blue ring, the cursor, goes round Request. The mode button at the bottom shows **EDIT**.

![The diagram page in the editor: the cursor ring round the Request node, and EDIT in the bar at the bottom.](/images/docs/screens/editor-tutorial/entered.png)

## Rename the first node

1. Press `cc`. The label clears, ready for you to type.
2. Type `Purchase request received` and press **Enter**.

![The Request node with its new label being typed: Purchase request received.](/images/docs/screens/editor-tutorial/rename.png)

## Add nodes

`o` adds a node after the cursor's node, joined to it by an edge. The cursor moves to the new node.

1. Press `o`, type `Check the budget` and press **Enter**.
2. Press `o`, type `Within budget?` and press **Enter**.
3. Type `:shape diamond` and press **Enter**. The node becomes a decision.
4. Press `o`, type `Raise purchase order` and press **Enter**.
5. To label the edge into it, press `ce`. A short code appears on the edge: type it, then type `Yes` and press **Enter**. The cursor is now on the edge.
6. Press `l` or **→** to move the cursor on to Raise purchase order.
7. Press `o`, type `Order goods` and press **Enter**.
8. Press `O` (Shift+O) to add a node that leads into Order goods. Type `Approve extra spend` and press **Enter**.

> **Jump to any node:** Press `f`, and a short code appears beside each node in view, except the cursor's. Type a node's code to move the cursor to it. If a node has no code, it is out of view: press **⌘0** (Mac) or **Ctrl+0** (Windows) to fit the whole diagram in view, then press `f` again.

![Codes a to e beside the nodes, after pressing f.](/images/docs/screens/editor-tutorial/codes.png)

## Connect two nodes with an edge

1. Press `f`, then the code on Within budget?.
2. Press `>`, then `f` and the code on Approve extra spend. A new edge joins the two, and the cursor moves onto it.
3. Press `cc`, type `No` and press **Enter**.

![The decision now has two labelled edges: Yes to Raise purchase order, and No to Approve extra spend, where the cursor is.](/images/docs/screens/editor-tutorial/connected.png)

> **The other way:** `>` makes an edge from the cursor's node to the node you move to. To make an edge the other way, into the cursor's node, press `<` instead.

## Give a node a class

A class names a role, such as a team. Each class gets its own colour: see [Colour-code with classes](/docs/classes).

1. Press `f`, then the code on Raise purchase order.
2. Type `:class Finance` and press **Enter**. The node takes a colour, and a legend appears.

## Add a comment

1. Press `f`, then the code on Within budget?.
2. Press `o`, type `Over budget needs the department head` and press **Enter**.
3. Type `:shape comment` and press **Enter**. The node becomes a sticky note beside the decision.

## Group two nodes

1. Press `f`, then the code on Check the budget.
2. Press `v` to start a selection. Then press `f` and the code on Within budget? to add it.
3. Type `:group Budget check` and press **Enter**. A group now holds both nodes.
4. Press **Esc** to end the selection.

## Delete a node and undo it

1. Press `f`, then the code on Order goods.
2. Press `dd`. The node is deleted.
3. Press `u`. Order goods comes back, and the bar at the bottom says what was undone.

![The bar at the bottom: EDIT, then Undone: delete Order goods.](/images/docs/screens/editor-tutorial/undone.png)

## Leave the editor

Type `:q` and press **Enter**. The mode button shows **VIEW** again.

![The bar at the bottom showing VIEW and the diagram's name, Purchase request.](/images/docs/screens/editor-tutorial/left.png)

With Line9 Pro, Line9 writes your changes into the diagram's text. Press **⌘U** (Mac) or **Ctrl+U** (Windows) to see it. In the preview, the diagram goes back to how it was before using the editor.

## What you used

| Keys                         | What they do                                    |
| ---------------------------- | ----------------------------------------------- |
| **Enter**                    | Enter the editor                                |
| `cc`                         | Change the label                                |
| `o`, `O`                     | Add a node after, or before                     |
| `ce`                         | Change the label of an edge                     |
| `l`, `f`                     | Move to the next node, or to a node by its code |
| `>`                          | Connect to another node                         |
| `:shape`, `:class`, `:group` | Change the shape, class or group                |
| `v`                          | Select several items                            |
| `dd`                         | Delete                                          |
| `u`                          | Undo                                            |
| `:q`                         | Leave the editor                                |

## Next

- [How the Line9 editor works](/docs/how-the-editor-works): modes, the cursor, and how to find what to press.
- [Editor reference](/docs/editor): every command, with its keys and mouse action.
