Diagrams are a great way to communicate ideas visually and can be used to extend or sometimes even replace textual documentations of software projects. This article describes how you can create diagrams without ever leaving VS Code.
Here are some use cases for diagrams. Maybe they inspire you to use diagrams more often!
- Documentation of how large scale components depend on each other:
- Highlighting relationships between classes:
- Page Transitions using Screenshots:
You can use diagrams for much more!
To create such diagrams in VS Code without ever leaving your editor, you just need to install the Draw.io Integration extension from the Marketplace:
After installation, you can simply create a
*.drawio file in the explorer view:
From there you get the typical Draw.io interface where you can draw your diagrams:
You can even use git to track changes of your Draw.io files!
Draw.io offers multiple themes that you can use in VS Code:
You can either directly create a
*.drawio.svg file instead of
*.drawio or convert any existing diagram to an SVG file. Such SVG files are still editable Draw.io diagrams! You can embed such diagrams in Markdown files and even view them on github. Conversion to PNG is also possible!
With code links, you can associate code with your nodes or edges by just naming the node like the name of a class or function and prepending the name with
#. So if you class is
MyClass, the node should be called
#MyClass. You also need to activate code links in the status bar. When you double click on a node with such a name, you jump to the class!
With Liveshare, you can even edit diagrams collaboratively!
Draw.io has much more to offer. You can use LaTeX for formulas, add free-hand drawings or paste screenshots from your clipboard right into the diagram!
All these features are also available for Draw.io in VS Code!