I used to use Snippets Text Database, but now I switched to Evernote. At some point I need to migrate all of my old stuff there too. What about you?

+4  A: 

I usually keep them in Visual Studio, although I got a fairly large amount of random .txt files in my Dev-Folder on my hard drive blush

Michael Stum
Haha, this is probably the worst way to do it, but it's the one I bet the majority use. I too have many random .txt, .cpp, and even a few random whole projects lying around for snippets.
Andrei Krotkov
+5  A: 

If they're common code patterns I integrate them into my text editor, for context-specific insertion with a few keystrokes. [Textmate Snippets]

If I'm going to discuss a snippet of code, historically I used pastie, but I imagine in the future I'll use gist.

Peter Burns
+9  A: 

Google Notebook. I have a notebook for code snippits and notes about languages, with each language having its own section. If, someday, that gets too large, I'll just break it down by category (eg languages and scripting languages). It's searchable, I can add comments below the notes, and I can share them with others.

Thomas Owens
Google Notebook is being retired. How long do you suppose they'll keep existing notebooks up for?
I love google notebook, why is it being retired??
I'm tempted to downvote since Notebook's days are numbered.
Evernote is has set up a tool to import google notebooks into evernote.
So has UberNote [] and a few others.
The Google Notebook service will be maintained. Development has stopped.
Stephen Denne
Development has stopped now, and the browser plugins won't be updated. How long do you think before they stop the service all together? I suspect this is an attempt to drive people to Google Docs - though that's not the same type of service and I'll agree that it doesn't fit the same needs.
+12  A: 

I have MediaWiki installed on a thumb drive (using PortableApps). I use it as a personal knowledge base for code snippets and any other useful programming tidbit I don't want to forget. This way I can take it with me anywhere and pull it up on virtually any computer I'm on.

+4  A: 

I use - helps other people as well (or so I hope)...

The social aspect is nice, but the ability to arbitrarily tag each item for organization is key. I really like this one because it's like delicious for code.
+1  A: 

I use Instiki, which is a very simple to setup, no frills, WIKI.

You could run this on any disk (e.g. portable USB drive, harddrive) and under any OS (I'm using it under Mac OS X). I keep it running in the background as I am working and switch over to it to add/view any kind of notes (including code snipplets) as needed and it works like a charm.

Ryan Delucchi

I have a big folder on my Desktop :), which looks a bit like this:


Yep, that's bash there! It actually has lots of things for using ANSI escape sequences but...
My "system" is designed so that I can just copy them use import LJPython or source Even in C#. It works quite well for me, because I hate having to get out of "the zone" to open a website or an application - an explorer window or a CMD is much easier.

Lucas Jones

Some of them I just leave inside programs. I have at this point mostly memorized where the applicable snippets are stored. A few of them I stuck on SO hidden in various questions and answers, some of which are favorited by myself.

Some of them are stuck inside utility classes so that snippet use is not needed at all. DRY is your friend therefore having a lot of snippets lying around is a bad sign.

+3  A: 

I'm using to store my code snippets. Mostly because it has a really nice integration with Textmate and an api which makes it possible to integrate it in other tools as well.


If you're running Mac OS X 10.4 or greater, Spotlight works a treat. Just shove them all into one folder (or separate folders). Click on a file, and then press Cmd+I for "Get Info", then put something in the Spotlight comments so you can easily find it later. You don't even have to do that though, if your files are plain text or RTF, Spotlight will look inside the file, so you can just have some text in your snippets like:

// C code to count number of bits in 32-bit integer

int population (unsigned int i)
    // code goes here.
+1  A: 

we use the Snippet Manger in vs08, and keep the .snippet files that could be used company-wide on the fileserver in a common location.

We also (being a share-point studio) have a Team site on our Sharepoint server with a list of snippets where they can be catagorized, sorted, and filtered.

+35  A: 

Anything that's really reusable becomes a class in my core library, so I don't really keep a collection of snippets.

And like any good library, I keep it in source control and regularly build new releases. Any of my projects that depend on the library get automatic bugfixes and performance optimizations whenever I release a new version.

Much better than a snippets library, if you ask me.


AnonJr's makes a good comment below, basically saying that the weight of the library can become a burden.

I totally agree. My personal core library (in Java) has more than 100,000 lines of code, and very few of my projects actually use all that stuff.

When I distribute an application based on that library, I actually use a dependency-analyzer (GenJar) to build a new JAR file, based only on the classes from that library that I've actually used in the application.

It's all part of the build-script, so I hardly even think about it anymore.

I like the idea, but sometimes the weight of the library is more than the benefit. Not often, but enough to make me think twice about it.
Also, sometimes snippets are not general enough to place into a reusable library. I might want to just store the simplified skeleton of a snippet that performs a certain algorithm so I can tailor it to my needs based on the project.
Sounds great for Java, but I get the sense that the question was a little more general-purpose than that.
Fair enough. But aren't there dependency analyzers for other platforms?
Even without dependency analysis pruning the library size, I still think a library is, BY FAR, the best mechanism for organizing a collection of reusable code.
@spoulson: Agreed. Sometimes its hard to fit a piece of code into a library. For me, one of the reasons is that Java doesn't support templates like C++. Those snippets still go in my library, but they're written using a simple code-generation syntax that builds custom Java when I need it later.
This is correct, except you would not have a single "core library" with unrelated features, you would have many lirbaries.
Ali A
Personally, I just have one library, though I suppose its more of a "util" library than a "core" library. I've thought about breaking it into separate pieces, but I haven't found any compelling reason to do so. Seems like it'd be more hassle than it's worth.
I think it's a great idea. But for me, snippets are needs for three reasons. The first, I had just been a newbie to a new domain. Secondly, I had no enough time. Thirdly, a algorithm implement, such as of computer vision or machine learning, sometimes is hard to be got done once and for ever and must be tuned according to the task object and context information.
Cook Schelling

If they're useful, I usually have them somewhere in the source code. If they're common, I put them in appropriate *Utils class (or) in my commons package. If they're made of drinkable magnificentness, I'll think about posting them on Stackoverflow or writing a blog post about it.

Apart from that, I don't really have snippets collection. Too much work maintaining it, and not once have I used some piece of code I thought was worth saving!

+6  A: 

I use gist, github's little pal.

+1  A: 

If it is a snippet that I use often, for example:


Then I'll throw

map #P O#!/usr/bin/perl

into my .vimrc file. Mapping #P to type out the snippet.

if it's significantly large, I use google notebook.

John T
+34  A: 

I like to write it up on my blog for two reasons. It helps me improve my writing and ensures I thoroughly explain the snippet. It also makes it quite accessible from wherever I may be.

+1, you're sharing with the world and providing free stuff to the code monkeys of the world, cool
This is a vastly better idea than the most upvoted one, so the bounty goes to it
+3  A: 

I'm using my brain - I've found it the most portable solution, and the lookup speed is unmatched by anything else. If memory assisted by IDE autocomplete can't easily reproduce it, it's probaby too "clever" to belong in production code, or should be part of an API library.

Michael Borgwardt
Bugfixes are getting less and less likely to be forward ported with time, I'm afraid.
+1  A: 

I use CodeKeep, this way my snippets are close at hand. If I'm at the office or at home i always have access to my most valued snippets (and a few thousand others!)

+2  A: 

I use GMail and label them with "Code".. Very easy to search and accessible everywhere. Good luck!

Ian P
+2  A: 

As silly as this sounds (and not to put myself on any kind of pedastal), I wrote my own snippet tool. I have to go back and check the links above, but at the time (a year or so ago without SOFLow) I just couldn't find a basic tool that wasn't free, or required me to have some additional IDE or anything installed.

So I wrote my own. It gave me a great change to try out SQLite (how I store the snippets) and it allows me to store my VB/C#/TSQL/HTML/CSS/Whatever snippets in an independent fashion. Plus it has the drag/drop, quick copy/paste type stuff I was looking for. It was a great coding exercise for me, I have a couple of colleagues using it at work, and I can easily port or export the app as needed.

Freely available?
<smiles /> Working on it. I wanted to get things "2.0" before I got it out, but I could shoot you a copy if you're interested.
+7  A: 

I use for the majority of my code, but I also use Code Collector Pro for some bootstrapping templates.

Tim K.
+3  A: 

There is no "Acceptable Answer" - use whatever works best for you and your work. For the few snippets I need handy I keep them in Dreamweaver's snippet repository. I also have a few .txt files for references that I keep on my flash drive for when I travel and use either someone else's program or my portable Notepad++ - But that's just me.

I could use Evernote, OneNote, Ubernote, a TiddlyWiki, or any of a million other things. In the end, what works for me may not work for someone else. Look at your workflow, and figure out something that works best for you and your situation.


I dont use code snippets any more. Just storing them in somewhere ready for copy & paste has the same disadvantages any copy & paste code has: when you find a bug, you have to fix it in many places.

I have tried to get rid of snippets by making it extremely convenient to put this working code into a reusable form. Now I have this setup: I have a Java project, with this layout:

  • java-independent-snippets
    • math
      • src
      • test
      • etc
    • swing_factory
      • src
      • test
      • etc
    • and so on...
    • build.xml

The directories "math" and "swing_factory" etc. each contain completely separate working code, usually just one source file with one or more methods. The build script iterates over all the directories and compiles each separately. So basically I have a directory and a source file for each snippet. To reuse a snippet, just create a subversion external directly to the sourcecode, or make a svn copy of the directory.

The next step is to add unit tests into the test directory, these too are automatically picked up and used in a continuous integration server.

Also, some sourcecode is for different java runtimes. For this I can have an optional in the etc directory of each of the mini projects, which is automatically picked up by the buildscript. This file also contains the maturity of the project, which I use to generate an overview of all the libraries:

# Maturity levels
# 1:  Pre-Alpha
# 2:  Alpha
# 3:  Beta
# 4:  Production/Stable
# 5:  Mature

With all this I have a very scalable system. It is extremely simple to add a new snippet / project, just create a directory and add the source file. The minimum requirement is just to compile, and if I want it can be extended with tests and more code as required.

+1  A: 

If code in Django, use

For my personal snippets I use and use it for team work.

Also since I code in VIM, I use SnippetsEMU.

+1  A: 

I don't keep snippets. Usually they're too specific to the project or data structure I'm working on. Plus, I'll probably have a better-fitting way of accomplishing the task next time.

David Grant
it depends I keep them because you sometimes (at least in Python and C#) do some generic stuff.
+1  A: 

ActionOutline allows you to store text in a tree structure as you see fit.

Jim Buck
+1  A: 
+2  A: 

I just store them in .snip files and let the IDE "Find in all" or google desktop search find them when I want them. I've mapped the file extension onto the IDE, so opening a snippet file gives me code highlighting and an easy way to copy the snippet into my code.

It's not very exciting, but it works for me.

+1  A: 

I use my case management / software development software... Fogbugz.

I just make a case, or email in the code with a suitable title in the subject so i can search for it later. I am considering creating an account of [email protected] so i can auto file them away as snippets I want to keep or links I want to remember.

What this does is provide me an instant search engine on the contents of the snippet in-line with my case manager.

Jas Panesar

I keep all my code snippets in a code repository. I've been using Subversion for 3-4 years, but recently I'm contemplating the move to GIT.

The snippets are loosely organized into object libraries based on their function. As I make changes to the snippets I check in the changes.

I'm a OSX user, when I need to find something, if I can't find it via the file structure (based on function), then I use Spotlight to locate the snippet I'm looking for.

+1  A: 

I have a private site on Google Sites, and I keep them there:

  • Easy to edit
  • Accessible from any web-connected PC
  • And since the page is a "File Cabinet" type, if they're actual Visual Studio snippets, I can add them as .snippet files.
+1  A: 

I have a small snippets project on

Mark Harrison
+2  A: 

I use personal wiki TiddlyWiki for my useful stuff not only code snippets. I can sync it to my website, so I can access it anywhere, anytime.

+2  A: 

There are different types of snippets, and how you handle them will be different.

Generally I have code for reuse, code I've come across that could be useful, notes, and useful links. Code for reuse needs to go in to version control - pick your poison, but anyone will do. Well call me old fashioned, but what's wrong with simple text files.

I think the problem is more down to how you organize your information, and what you use to search. I have a well laid out folder structure, which I can search. I also can have a copy of anything in version control in this folder structure too. There are numerous tools that will do a good search of text in folders - Spotlight, Google desktop, various editors, grep.

I say keep it simple, then you never have to worry about database formats, moving from platform to platform etc.

I've also taken to using DropBox as a way of syncing it between machines and having it accessible from the web.

Miles D

I use StackOverflow. Simple code (such as hexadecimal conversion) to interesting algorithms (polygon rendering) to tips and tricks.

The reason why is that no single repository I've ever used has suited me - I need to access it everywhere, on any computer, it needs to be easily searchable, and it needs to require little to no effort to keep up to date, modify, note, find, test, etc.

Google does the searching for me, and StackOverflow holds it. Further, others improve it - almost like an open source project - noting corner cases, problems, suitable and unsuitable uses, etc.

The internet is my brain, and I don't have to worry about cross platform issues, moving it from one type of media or platform to another, backing it up, etc.

What other tool is so powerful and useful?

The only drawback is that I don't have access when I don't have the internet. That's really not an issue, though, these days. The internet is as important a programming resource, nearly, as the compiler.

Adam Davis
+1  A: 

StackOverflow! If you have a code snippet worth saving then it's probably the answer to a question that others will have as well. Ask that question and then post your snippet as an answer. Next time you need it you don't have to even remember that you put posted it on StackOverflow -- it should come up in a google search.

+1  A: 

Well, for a start, it depends on your definition of a snippet. I divide these in 2 categories:

  • smaller pieces of code which I often put in my programs (repetitive stuff)
  • some pieces of code which I think I will use sometimes in the future (for example, some function, subroutine ... in your case this may be some class or something - depends on the language you use) ... these are as a rule, somewhat bigger in size ...

For first, I use SnippetsEmu plugin in vim. (for those prefering emacs I would recommend YASnippet)

For second I used to use just a bunch of plain text files, all in one directory, and then I would go through them with a search tool (grep, some gui search tools, find, ... these varied with time). Every once in a while, I go manually through that directory and filter out what I think I'll really need, by the rule of "if you haven't used it in the last 6 months", and delete the rest. Then the stuff I consider useful I put in one file conveniently named snippets.txt, and comment it out with a useful line or two. But then again, that's just me. For someone who's using several languages in their work, some tool for keeping snippets according to language would surely come in handy. Just the other day, while searching for something else I came across this thing - Code Warehouse

I downloaded the trial version, and it works nicely. Tree view, syntax highlighting for several languages ... everything ... I don't like the fact that it puts all your stuff in a database file, but someone will probably find that convenient as well. I just don't work often with databases, so it's a little bit confusing to me. The downside is that it is not free. If someone knows a free version of a program with those capabilities, I would be interested to hear about it.

Sorry because of a little longer post.


Opera , Blogger, Gmail and Gears.

In Opera Ctrl + 5, to open my Edit posts window , start search and view. With Code Formatter I might even get some syntax highlighting ; ) When I do add some new code snippet Blogger sends an email to my Gmail and when properly tagged it could be found from there by searching: from:me good tags, Enter

+1  A: 

+1 for DropBox (which, for those who don't know, is a very clean implementation of the local-folder-tree-synced-to-the-cloud idea). Here's why:

  • Your snippets file is stored locally so you can get to it very fast with local index searches such as Spotlight. Web-based services seem like they'd be a lot slower, keystroke for keystroke. (I can get to almost any snippet without touching the mouse.)
  • It's just a file in the local file system, so there's no need to leave a browser window open or log in to anything.
  • It's cross-platform Win/Mac/nix, for those of us who develop on various platforms.
  • If you put it in your /Public folder, it's also on the web, for indexing, sharing, linking, etc.

In version control, in a user directory. It's available for all, under SCM and out of the any project's directory.

Brian Carlton
+3  A: 

I have a similar story. I used to store snippets of code in the Evernote before. However, at some point I decided to get rid of this workaround and, probably, to help other developers.

As result, we together with my friend have made an application that solves exactly this problem. We are both using Macs, so the application is Mac-only and it is obviously called ‘Snippets’ :)

It is still in development but is already working well and we are moving to the release very fast. Please, do not hesitate to give it a chance and request any features you wish to have. Thanks!

Vladimir Prudnikov
Would love to have this for Windows too.
We have no plans to make Windows version in the near future, but it's possible ;).
Vladimir Prudnikov

I use a newer service called CodeBarrel since it is secure and I kept leaving my stupid flash drive at customer locations with all my code on it. It was password protected but still, yet another drive gone to be replaced.

+2  A: 

I just bought and recommend Snippets. One licence covers as many personal computers as needed and I can keep it in sync by storing the database in my dropbox.

Snippets - "Stop Reinventing the Code"

Snippets is a powerful application for Mac OS X that stores the most valuable pieces of code you can reuse in different projects many times.

The main idea is to make the process of reusing as easy as possible to avoid wasting your valuable time to write the same code again.

Using such powerful features as smart groups, labels, and integration with other applications increases the speed of coding.

It is a Mac only desktop client available in any app via hot-key, free 30 day trial and $39.99 with a 25% student discount.

I really wanted to use Evernote but it has such poor text editing that it makes maintaining code unbearable.

A few things that made me buy Snippets:

Others you may be interested in is:

PS. I put in my ref codes in a few links, I don't make any money I/we just get extra online storage space (I hope I am not breaking the rules, if so I can remove them).