5 Ways to Manage Your Code Snippets Easily & Effectively

If you write code for a living, you undoubtedly have some snippets holstered. Those random bits of code end up making entire websites, services and apps run, but how can you keep track of them all?

In terms of the coding process, you’re still going to Google everything all the time; that’s never going to end. Having a home for your snippets is a good practice to get into, though. It’s faster, and you can corral simpler actions (like that time you forgot how to initiate something, and felt dumb) you’ll undoubtedly forget randomly.

There are tons of ways to manage your snippets, but here are our (language agnostic) favorites.

Code Snippets, Meet Quiver

Quiver is one of the most powerful code management tools around. Available for macOS, it bills itself as the “programmer’s notebook,” and that’s a really fair assessment.

Feature-rich, Quiver has far too much going on to discuss fully here. One of the handier features is the ability to mix text with code. It’s like commenting your own code notebook; you can add information or notes to yourself, and place snippets in unique cells so they’re easy to discover and copy-paste (let’s not stand on ceremony; you do a lot of copy-pasting in your life).

If you want to get really quirky, Quiver lets you edit its CSS. There are also features for presenting views (i.e., classroom or office presentations), and tooling to allow teams to manage a single notebook. It also allows for multiple notebooks, which is great for those who hop between several different languages or technologies.

We can’t say enough about Quiver, but we have to stop sometimes. Really – give it a look. It’s great.

Quiver Code Snippet Management Tool Dice
Quiver

Dash-tag ‘Code Notes’

Dash also has a lot going on – it’s just a touch unfocused. Its main purpose is to let you manage code and search various documentation without ever leaving the app, which is about as convenient as it gets.

It does this by downloading entire docsets onto your machine and poking through the web. Viewing it from my own narrow scope, I’m able to search through Apple’s API reference guide and sample code, filter Stack Overflow results for Swift, view the Swift GitHub repo, and find user-generated Swift ‘cheatsheets’ in one view.

On top of that, Dash is a very respectable snippet management tool. It’s a bit less fussy than Quiver, and has a really neat feature that recognizes when you’re typing code; it starts color-coding code snippets. You can go from notes and comments to code very naturally with Dash.

Whereas Quiver leans hard into code management, Dash tries to straddle a lot of fences. It has several search plugins for IDEs (though it’s dropped Xcode support, so tread lightly, iOS developers), and pulls from a dizzying number of sources to help you discover fixes for your problems. We really enjoy the ability to leave it all in one app, but Dash may be trying to push too many levers up to ’11’ on its dashboard. If a feature you really love about Dash vanishes, don’t be surprised.

Dash
Dash

GitHub (Yes, Really)

GitHub has a really neat feature named ‘Gists’ that lets you – well, add gists of code to your profile.

It’s underutilized, but we really like it. You simply name and describe the Gist, give it a filename, and add your code. You can edit how many spaces it indents, and whether code wraps or not. There’s also a feature to add files, should you want to better manage things such as inheritances in your code. And that’s about it!

Gists can be public or private. Private Gists are obviously meant for your eyes only, but we also think public Gists are a great way to share knowledge without writing full-fledged apps, and can be a good resource for your next interview or performance review.

GitHub Gists
GitHub Gists

Plaintext Code Management

Your computer probably has a text editor, and you know it’s good enough for basic snippet management.

It’s not fancy. There’s very little styling you can control, no search, and no documentation features baked into a text editor. It’s about as cold and static as you can get.

Still, snippet management is possible via this method, and it allows for granular control over where files are stored. If you’d rather have a myriad of TextEdit files strewn across your desktop, go wild.

Code Notes

Code snippets are basically notes. So why not use your favorite note-taking app?

If you’re the type who uses a note-taking app to manage to-do lists or gather other random bits of information, why not use it for code, as well? I use Apple’s Notes app, and find managing folders and files is far easier on desktop. It’s a handy way to maintain code snippets as unique notes, and allows for the addition of links as well as highlighting and such.

Sadly, note apps still aren’t meant for code, so you will miss the features of Quiver if you go this route. A note-taking app is really just a step up from a text editor.

But they’re always cross-platform, so you won’t have to make random notes to change code when inspiration strikes as you’re out to dinner. That’s a feature we really enjoy about using a notes app for code management.

Code

Manage Your Code, Manage Your Life

Code is meant to be reusable. Not managing snippets is almost irresponsible. Why dig through old apps when you can copy-paste and take a few notes, then use the same code later?

We also like code management tools because they allow you to make edits in one place for use later. Your language may have changed a feature or methodology, or you simply found a much better way to perform a task. If you have a code snippet manager, you’re more likely to remain up-to-date for new apps. It’s also helpful when refactoring.

If you’re looking for a recommendation, this article is a top-down list of our favorites. Quiver is far and away the best, most powerful code management tool we’ve seen. It’s got a learning curve, and we wish it were available outside of macOS, but it’s really good. There’s also an iOS companion app (Dash has one, as well).

There are many other code snippet tools available (Lepton and Boostnote come to mind), but they’re quite honestly clones of one another or lacking important functionality. This is part of the reason we like GitHub Gists if Dash or Quiver aren’t available to you; Gists are available anywhere via the web, and it’s a lightweight way to interact with your code snippets if you just need simple management.

Related

2 Responses to “5 Ways to Manage Your Code Snippets Easily & Effectively”

  1. I’m still deciding whether I want to keep code snippets in a place that everyone has access to though I know some folks who swear by keeping these in a cloud-based repository (One Note, Evernote, and the like). I have, for years, built up a private repository of snippets under my home directory ($HOME/include/concepts/) so I don’t have to dig around in numerous subdirectories looking for an old piece of code that I have to cut-n-paste code from.

  2. Since it mentioned plain text files, Mac users have another option: select the code/text and drag it to the desktop or into a Finder window (such as if you create a folder for it). It creates a text snippet which can be copied or dragged into a text field. I find this handy for repeatedly grabbing bits of code from files or websites.