What do you guys use to store and retrieve Snippets of code?

Your thread is much like the one I started a couple of years ago:
What Do You Use for a Code Snippet Tool?

My last post there was:

While I still like Quiver, the limitations of its search (primarily no Spotlight search), have led me to another approach.

TLDR:
So I have evolved to now primarily using macOS files with Spotlight search. After more than a year with many requests by many users, the Quiver developer has not provided Spotlight search. So, I'm moving away from Quiver.


I have scripts stored in multiple locations:

1. My AppleScript Script Library (all of my core AS handlers)
2. My JXA Script Library (all of my core JS functions)
3. macOS Files
  * Scripts used with KM
  * "How To" and text scripts
4. Quiver (moving to files or text expander)
5. TextExpander (moving to Typinator)
6. Evernote (when I need extensive documentation to go with the script)
  * Often I will have a link to the script file / library
  * In script file header comments, I will have a link to the Evernote Note
  * Evernote is also searchable by Spotlight

Fortunately, `#1-3` and `#6` are searchable by Spotlight.  With these I make good use of text tags (like "@KM"), an idea I got from @ccstone.  These are simply one-word text keywords with a prefix of "@", put in both the file name, and in the script file as comments.  Using Spotlight to search for "@TagName" is very fast and effective, with very few (if any false positives).

I am also experimenting with use of actual macOS Tags.

I view snippets in two categories:

1. Complete handler/function
  * For scripts for my use, I use a ref to my script library
  * For scripts posted for others to use, I usually extract the handler and put in the same file as the main script.
2. Short blocks (often 1-line) of code to be inserted (with placeholders) into the script.
  * Stored in TextExpander (moving to Typinator)
  * Typinator has some great search and organizational tools.

I have an ongoing project to build a handler/function tool in KM, that will allow me to search my script libraries, and then extract either the call to the handler/function, OR the complete handler/function, to be inserted into my open script file.  This will use the great tool by @DanThomas [MACRO: Spotlight Search Prompt](https://forum.keyboardmaestro.com/t/macro-spotlight-search-prompt/4665) 

What I have learned over the last few years is that there is no one snippet manager that will meet all of my needs.
2 Likes