Redux: Snippets were the original "IDE"
Well, it's been some months since I wrote Shower Thought: Snippets were the original "IDE" and I have to say, the honeymoon period is kind of over.
I now have something like 50-odd snippets for various languages and tools. I still use them quite frequently. However, as a 'replacement' of intelligent completion, they just don't stack up.
First is the problem of discoverability. I mentioned in the previous post how I would use snippets to generate Bash boilerplate which I didn't remember. Now, I've found that I use these snippets so often I kind of just... remember them. I've used the snippet so much I went from "I'll never remember this, I'll just do it the wrong way instead," to "Oh I've seen this 10 times this week, of course I remember the right way to do it." The snippet is still faster than typing it by hand, but it's literally so familiar now that when I'm really in a flow state, I'll forget I even had the snippet and start trying to do just that! And honestly, Bash is the only language that I write in where there's so many different wrong ways to do one thing. It just isn't as effective for something like Python. (Naturally.)
Second was the problem of building a common template.
This kind of includes discoverability, as you can put options in the template that you might not remember, but it's moreso that it helps in creating a common and familiar structure across different files or codebases.
I used Ansible tasks as an example of this.
The Ansible copy
module has so many goddamn options that I made a template for the most common ones, so my invocations of copy
were easier to write and looked all the same.
I've found, though that striking a balance with this kind of snippet is actually quite hard.
If I put in all the options I don't quite remember the syntax for, then I end up deleting more than half the snippet a majority of times I use it.
If I don't put in enough options, then I have to use an LSP or go look it up, which completely defeats the purpose of using a snippet (for this task) in the first place.
One use for snippets that I've stuck by is having per-project boilerplate.
As in, certain tasks I work on are required to have a standard copyright header at the top of each file, and maybe some very common definitions or imports.
I can create a snippet like !project
and then bind different copies to different syntaxes to very quickly create new files.
And that's something that an LSP can't (and really shouldn't) handle.
After some time really using them, I think this is probably how most people actually use snippets - not as a companion or a replacement for auto-complete and Intellisense functions, but as a completely different IDE feature.
As I said in the last post, maybe I'm the Slowpoke and everyone already knew that, dumbass. But I feel like I'm still learning the snippet game, slowly.