I’m a huge fan of Espresso from MacRabbit. While it’s not perfect, it’s my code editor of choice at the moment. One of my favorite features of Espresso is that it’s functionality can be extended using Sugars. After downloading Themes and Sugars to assist with development and creating a few code snippets, I realized one small problem: there was no way for me to share them between all the computers I was using Espresso on. Thanks to some help from the MacRabbits/Espresso team and Dropbox, I’ve been using a solution that’s been working great so far!

The first thing we need to do is set up Dropbox. I would suggest creating a folder called “Espresso” to house all our Espresso stuff, then inside that folder create a folder for Themes and one for Sugars. It’s your Dropbox though, so the choice is yours!

Next, we’re going to place all our code snippets in a Sugar. Normally, you would just create code snippets in the “User” section of the Snippets window within Espresso. While I won’t go into full detail on how to create a Sugar, you can get a detailed explanation as well as a Sugar template from the Espresso wiki. I would suggest reading through that first.

Rename the template folder to whatever you’d like to name your Sugar (I named mine “Snippets-sugar”) and place it in the Sugars folder in your Dropbox. Inside your Sugar folder, create a folder named “TextActions” and inside that folder create a file called “Snippets.xml”. Here’s a basic template for Snippets.xml:

<?xml version="1.0"?>

    <snippet id="com.macrabbit.text-actions.css.open-bracket" category="hidden">

        <text-trigger key-equivalent="{"></text-trigger>
        <text>{ $0 }</text>
        <language-context>css, scss</language-context>


    <snippet id="com.macrabbit.snippets.css.template" category="tools.Snippets">
        <title>CSS Template</title>
        <language-context>css, scss</language-context>

        Your code snippet goes here.



The first snippet is copied from Espresso’s default CSS sugar and completely optional, all it does is get rid of Espresso’s multi-line CSS (I like my CSS on a single line). When creating a new snippet, make sure it has a unique ID, I find a good pattern to use is “com.macrabbit.snippets.[language].[identifier]”. Update from Ian at Macrabbit: “For snippet IDs it’s actually best to use your own domain (or something arbitrary) instead of “com.macrabbit”; this will reduce the chances of an accidental collision with internal Sugars. Although this isn’t strictly enforced by the program at the moment, we reserve “com.macrabbit.*” and “espresso.default.*” for internal use; otherwise you can put pretty much whatever you want for the ID string (reverse domain formatting is what we recommend simply because it cuts down on the likelihood of collisions between third party Sugars).”

You’ll also want to create a title for your snippet, specify which file types can access it, and a text trigger to use. The example above is the set up I have for my go to CSS template (have fun with your text triggers!). When it comes to actually inserting your code, make sure you wrap it in a CDATA tag, and take note of the spacing because it will insert into your document with the same spacing it has in the XML file. I would suggest aligning your snippet to the far left.

You’re done with the hard part!

Finally, we’re going to create a symbolic link for our Sugar. This creates a “folder” in the Espresso Application Support folder for Sugars, but the contents of the folder point to your Dropbox. Open up Terminal and copy and paste the following one line at a time:

cd ~/Library/Application\ Support/Espresso/Sugars
ln -s MySugar-sugar MySugar.sugar 

Replace “MySugar-sugar” with the path to your Sugar’s folder in Dropbox (ex: /Users/[your user name]/Dropbox/Espresso/sugars/Snippets-sugar) and replace MySugar.sugar with whatever you’d like to call your Sugar (ex: Snippets.sugar).

For themes, you can skip the first part, you’ll just need to set up symbolic links for each theme you’d like to share. You don’t necessarily have to use Dropbox either, you could also use Github as many Sugars are hosted there to begin with. Just fork the Sugar and point the symbolic link to the repository instead of your Dropbox.

I hope this helps you as much as it has helped me! Leave a comment if you have any questions or suggestions.