Skip to content

Instantly share code, notes, and snippets.

@olange
Created January 4, 2015 00:21
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save olange/6834323ffc613b2ba25f to your computer and use it in GitHub Desktop.
Save olange/6834323ffc613b2ba25f to your computer and use it in GitHub Desktop.
Graphviz (DOT) Build System for Sublime Text 2 and 3

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"
}

Usage

  • 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.

Installation

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).

Troubleshooting

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

@albertofwb
Copy link

it works on windows

@jpeyret
Copy link

jpeyret commented May 15, 2017

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 reported path 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 with subl and which solved the issue (there is a plug in somewhere to get the full Mac system path too).

@javacraft
Copy link

Thanks for this Gist, works great on CentOS7. I came across this as an alternative to GraphizViewer plugin, which appears to be broken.

@CoolOppo
Copy link

Thanks a bunch, works great.

@lin71008
Copy link

Thanks for this. It works on windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment