Skip Navigation

How do you manage code snippets?

Do you keep them in your IDE, or elsewhere? Do you have an app for that? Are they easily shared?

I realized I have no system at all but could use one to make it easier to find code I've written and might need again some day.

By snippets, I am referring to any chunk of code / text in any format or language, of any length.

Thanks!

EDIT A DAY LATER: Thanks you all! Reading all these ideas, I got inspired to create my own little web app. Wish me luck... :)

56 comments
  • I go full chaos and look up where I last used it when I need a snippet...

    • It's got to be here somewhere... (Search for way too long.........) Dang, I guess I'll just write it again from scratch

      Yeah, this is what I am looking to avoid.

      • I have a weird knack for reverse engineering, and reverse engineering stuff I've written 7-10 years ago is even easier!

        I tend to be able to find w/e snippet I'm looking for fast enough that I can't be assed to do it right yet 😆

  • I selfhost Snippetbox. Real easy, limited in features but does the job!

    • Thanks. I am thinking about whether a self-hosted service is overkill for this, for my purposes. I kept my question broad in order to find out if most people just keep their snippets on their own PC or what.

      I will check this out and I'm also looking at Snibox.

  • Jetbrains IDEs have “Live Templates” that I use extensively.

    For little notes and snippets (especially CLI snippets) I use an app called Stashpad, which I LOVE.

  • I have like a zillion notepad++ tabs. Every once in a while I'll go through the tabs to see if I want to save the snippets.

  • Vscode syncs them across all my computers (and even into browser sessions), so I use that.

    If you’re meaning a place for code, I have a private scratchpad repo

    • I work in VSC most of the time too, so using its built-in user Snippets feature seems to make the most sense. How do you get it to sync across computers? (I can go look into that if it's a native feature)

  • Back when I used macOS, I liked an app called SnippetsLab. Nowadays, I just throw them in Emacs Org files. Emacs is actually very handy for this, you get syntax highlighting in the code block, you can execute the code right from inside your Emacs environment and there's even alpha support for lsp-mode inside of Org code blocks.

56 comments