(This challenge was again created by guest contributor Giovanni Lodi.)
Today’s challenge: spend 20 minutes getting snippets support configured in your editor. (If you’ve already done this, then spend some time adding a new one or two. Maybe delete some old ones you never use. Tend your snippet garden.)
I think it’s worth being fairly intolerant of unnecessary typing. It’s slow, error-prone, and puts mileage on your hands.
Let’s type less and get more done faster.
Here are some places to start. How to make snippets in…
If your development environment doesn’t support snippets, you can use a third party tool to bring snippets to all apps. On macOS, Alfred and Dash are great.
Good one, I had forgotten how many “Live Templates” I actually use, and that I can modify them myself.
Using IntelliJ-products mean I’m pretty used to typing a few letters of the class name and hit enter - but this can do so much more!
I use PhpStorm frequently with Laravel, so I’ve set up some snippet/templates around the Collection framework.
Great reminder! I used to have a couple of them in IntelliJ some years ago and must admit I forgot about it. Since I’m now starting to use IntelliJ more again because of a new project I joined recently I had to look up the syntax again. The main one I use is @Test<TAB> to scaffold a new JUnit test method placing the cursor at the method name and then in the method body (i.e. $END$). After a couple of tries I have that one working again. I wish there was a simple way to extract these custom snippets so that I can commit them with my dotfiles.
I don’t care for things meddling with my typing. I find typing is not the slow part of programming – the thinking takes much longer.
That said, there are a few things that require annoying boiler plate (nested_attributes I’m looking at you). So I’ve taken today’s task as a documentation goal adding better examples that we can snag from our internal libraries.
I’m going to put hands on tailwind css, so I installed several extensions to make learning easier. Surprisingly, I was not a fan of snippets and autocompletions for historical reasons. Maybe, It’s a good chance to change some habits. will also check other tools.
typing is not the slow part of programming – the thinking takes much longer.
That’s absolutely true. One could argue that investing into sharpening our thinking tools, e.g. by exploring a new programming language to see how they do things differently or reading about mental models.
Still, I’d argue that investing a bit of time into removing friction from the process of materializing your thinking into code, words, actions is useful, too.
Not being an Emacs user, I didn’t know about yasnippet. I’ll add it to the list. Thanks.
How do you use Emacs? As in, what do you, Julian, use it, not how to use it general . What do you find useful as opposed to using a text editor like VSCode and going to terminal just to run commands?
I probably used any combination from full blown IDE to sublime to vim. Actually I‘m still using vim keybindings.
Honest to God, I cannot really tell you the exact reason why I use it, I‘m not even a good emacser. It’s probably a combination of strong muscle memory (I‘m a musician), extensibility to the max, integrations and features.
For example I never wrote one line of Vimscript. Then, three weeks into my emacs usage I wrote a custom function to trigger my Harvest timer and annotate it with the current git branch and project.
I’m all for sharpening tools mental & mechanical. And for everyone who enjoys snippets, more power to ya. I’m a long term vim user and try to actively practice, that is the way that I focus on reducing friction when materializing code – there are many paths to less friction.
Also, I’ll second your recommendation of that mental models site. I’ve really enjoyed it. Great to mention here!
Had never really used snippets before. I knew that they were there… But hadn’t got around to investigating them. Thanks for the prompt the read the IDE manual again and get some learning in.