So, I've written a few posts in the past about storing code snippets and my various attempts at finding the right tool for the job. I've tried plain text, TWiki, and Evernote in the past. However, I've now finally(?) settled on Workflowy for both this as well as many other things. I really think I've found the sweet spot here for code snippets.
Workflowy is basically an outliner where you can have different levels of nested bullet points. Sounds pretty boring right? Well actually, no - the immense power and flexibility in Workflowy comes from the fact that you can change the current context to be any node in your hierarchy. Effectively zooming in and out, and working just within the context of that node and its children.
So that means you can store a HUGE amount of information in Workflowy - eg. multiple projects broken down to any level you require, notes, todo lists, recipes, gym workouts, inventory, holiday information, and anything else you can imagine. Oh yes, and code snippets too ;) The hierarchical nature pretty much makes this a mindmap tool which you can model however you see fit.
So back to code snippets. Each node in Workflowy can have a text-based note attached to it. So I use this to store my snippet for that item. Then I use the the bullet point hierarchy to structure my snippets - first breaking them down into language, then category, then description of the snippet. Then I attach the snippet as a note to that description. It's probably easier to explain with a screenshot ...
The above screenshot is my snippets node with all the sections collapsed. I can either click on a plus (which appears on mouse-over) to expand that node; or I can click on the bullet point itself to zoom in...
Then in each of those, I can drill in again and again until I need to write the snippet itself, which looks like this ...
Then, I can copy and paste straight from the note. Or if required, edit the snippet straight from there.
Another great thing about Workflowy is that you can share a node and it's descendants. You can either share to another Workflowy account, or you can share as a URL with one of those cryptographic hashes in the URL so it's not discoverable. This makes it much more portable if you don't want to be logging onto your personal Workflowy account, say from your workplace computer. All you need is a bookmark.
As I mentioned earlier, I've been using Workflowy for snippets for quite a while now, and think I've finally settled on this as my snippet solution. Whilst I do have a paid for account, the free version is certainly more than enough to get by for a lot of applications. Having quick access to my snippets has saved me so much time, rather than having to waste time Googling or rewriting segments of code that I've already written many times before.