To transform the currently opened Graphviz source file (in DOT Language) into a PNG:
{
"cmd": [ "dot", "-Tpng", "-o", "$file_base_name.png", "$file"],
"selector": "source.dot"
}
- Open a Graphviz source file
- Hit
CMD-B
from your editor - Open the rendered PNG file from within Sublime (it will display it)
If you place the PNG side by side with your DOT source file, you'll see the PNG automatically refresh with each build.
Create a new build system (_Tools > Build System > New Build System...), copy and paste the above content in the editor, and save it as Graphviz.sublime-build
(should automatically go to the Packages/User
subfolder of Sublime Text).
This was tested to work on Mac OS X, Sublime Text 2 and 3. To get it work under another OS, you might need to add OS-specific options; see Build system specific options
macos: Mavericks, Sublime 2, dot installed via macports (not homebrew).
didn't originally work for me, probably because dot was not found. the original error was
file or directory not found
, but the reportedpath
looked fishy - i.e. it didn't include directories where macports puts executables. looking at https://forum.sublimetext.com/t/how-to-set-path-on-os-x-so-sublime-can-see-it/11842 I restarted Sublime withsubl
and which solved the issue (there is a plug in somewhere to get the full Mac system path too).