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:
![](https://docs.yarnspinner.dev/~gitbook/image?url=https%3A%2F%2F3844916845-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FW7FKDVQjKCuUze7DY3br%252Fuploads%252Fgit-blob-dcbc67e4dd640185661dccadce464c68d8555fcf%252FScreen%2520Shot%25202021-12-20%2520at%252012.11.07%2520pm.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=3d48d8a6&sv=1)
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:
![](https://docs.yarnspinner.dev/~gitbook/image?url=https%3A%2F%2F3844916845-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FW7FKDVQjKCuUze7DY3br%252Fuploads%252Fgit-blob-426b1b6f0ebdc7ac92c5a16368ec1d8d1434760e%252FScreen%2520Shot%25202021-12-20%2520at%252012.11.14%2520pm.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=6b564978&sv=1)
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:
![](https://docs.yarnspinner.dev/~gitbook/image?url=https%3A%2F%2F3844916845-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FW7FKDVQjKCuUze7DY3br%252Fuploads%252Fgit-blob-b29c93a20f2a681cabc20a81b346c758869a4c5d%252FScreen%2520Shot%25202021-12-20%2520at%252012.11.32%2520pm.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=eaf99f5f&sv=1)
You can use the "Add Node" button to add new nodes. New nodes will appear in the Graph View, and in the text editor:
![](https://docs.yarnspinner.dev/~gitbook/image?url=https%3A%2F%2F3844916845-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FW7FKDVQjKCuUze7DY3br%252Fuploads%252Fgit-blob-476222547211a46b51b9787c8e06cc4b18bc89c9%252FScreen%2520Shot%25202021-12-20%2520at%252012.12.03%2520pm.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=3667bc6a&sv=1)
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:
![](https://docs.yarnspinner.dev/~gitbook/image?url=https%3A%2F%2F3844916845-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FW7FKDVQjKCuUze7DY3br%252Fuploads%252Fgit-blob-4db27fc5a6a02f115d68050c4990b9ed86fc5565%252Flinks_vscode.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=d649d6e6&sv=1)
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).
Last updated