How do you keep track of your code snippets?

i maintain such a collection not only for myself, but for an entire publishing production staff. when i come across a good solution to a frequent problem, i create a small self-documenting file with an "obvious" name, process it, and put all the resulting files into an area named howto. the "first" file in this area is called 00index, and into it i put a brief entry stating the purpose of the test file and its name.

the self-documenting feature is something i find particularly useful. it depends on the verbatim package, and the general idea is this:

\documentclass{...}
\usepackage{verbatim}
... % definitions here
\begin{document}
... % illustrative example here
\vspace{2\baselineskip}
\verbatiminput{\jobname.tex}
\end{document}

the output shows the example followed by the full content of the file so that the input can be studied along with the output. printed output is easily filed in a binder for reference off-line. the index can also be entered in a wiki with links to the pdf output.


It depends a bit on what it is. If it's a bit of actual TeX code then I either make a new style file for it (which I keep in a BZR repository) or I add it to my "default" style file (which I load for almost every document I write, and which is also version controlled). If it's a way to do something, then I write a short note about it and put it on my webpage. I have an area called "How Did I Do That?". The intro reads:

Collected here are a load of hints, hacks, and howtos that I have used at some point to get my computers to behave the way I want them to (as opposed to me behaving the way they want me to). Often these only need to be done once, until I do something stupid like upgrading my system. By that time, however, I've usually forgotten the details of how I did whatever I did. So I've started keeping notes. I'm switching to keeping these notes in a blog as the most useful resource that I've found is other people's blogs explaining just how they got the text in their xterms to be mauve. So I've put these here just in case they are useful to someone else.

The LaTeX-specific section is here (though there's one or two others scattered about that site).

Often I find that the very act of writing it down commits it to memory, so I don't all that often look at the collection of notes! But if it weren't there, I'd need it.


For MacOS X I can highly recommend Notational Velocity. Conceptually it is a collection of index cards with incremental search. I keep TeX (and other) snippets there. Finding a snippet is as easy as starting to type anything that I remember about it. Notational Velocity is open source.

Screenshot of Notational Velocity

Tags:

Big List