# Writing Yarn in VS Code

With the Yarn Spinner Visual Studio Code Extension installed, you can make new Yarn files, and edit existing ones, right inside the VS Code editor.

### Making a new .yarn file

You can use the File menu -> New file command to make a new empty file. Simply save the file with a .yarn extension to activate the Yarn Spinner Extension features.

### Opening an existing .yarn file

You can open any existing .yarn file, or collection of .yarn files, using VS Code:

![Selecting an existing .yarn file](/files/GzWcU3uZXIw0uJX7W5xn)

**With a .yarn file open, you can edit it in the text editor.** The chosen .yarn file(s) will open, and you'll be able to work with them, edit them, and save them as needed:

![The .yarn file open](/files/xweR4xguMEPIR7kV4LMh)

**You can show and hide the Graph View.** If you click the "Show Graph" button, in the top right-hand corner, the Graph View will appear:

![The Graph View](/files/O4J8ne3CgWXnihBV6X2y)

**You can use the "Add Node" button to add new nodes.** New nodes will appear in the Graph View, and in the text editor:

![The Graph View will show all nodes in the active .yarn file](/files/ty3pdadqb87X3S8s5ucy)

**Links (for example, using the jump commands) between nodes will be visualised in the Graph View.** You can use the edit button on a node in the Graph View to jump to the appropriate location in the text editor, and you can rearrange the nodes visually in the Graph View for ease of understanding the relationships between areas of your script:

![Links between nodes in Visual Studio Code.](/files/cqUZ2c3JMUDRvBP7GQ24)

**You can also use the "Jump to Node" button to move to a specific node in the Graph View.** This allows you to easily move between areas of your text script. Nodes in the graph view can be rearranged for convenience; this won't impact the text version of the yarn script other than updating the position (below the node title).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yarnspinner.dev/2.2/getting-started/editing-with-vs-code/writing-yarn-in-vs-code.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
