Snippets are huge, and I didn’t realise this until just now. A while back, I decided that I should start collecting snippets and build up a massive catalogue of them. But I wasn’t doing much work back then so I wasn’t coming across much code that I thought I might reuse. So my snippet phase faded. But it has returned.
I recently just go back to university and I’ve started coding a lot more now. What better time than now to start collecting snippets. But I’ll tell you a better time to start collecting snippets.. the start of your career. Now that I’ve started, I’ve noticed how much code I share between projects. All of that time you spend repeating yourself is time wasted. So you want to start collecting snippets as soon as possible. Now you just need somewhere to store them. Enter Dash.
I’ve picked up and dropped Dash a number of times over the years and I’d always end up uninstalling it because “I didn’t get it”. Why would I need the documentation offline? (Why do I even need it at all?) But this time I was going to make it work. I’ve recently just picked up development again on my final year project, which is done in Ruby on Rails, and I’ve also started a Wordpress theme for Grace. I thought this would be a good time to test out Dash for referencing the docs on both of these, and it’s proved very useful. With loads of integration with other apps it makes searching for what you need super easy. My favourite is the Alfred workflow. Super simple. Super awesome.
But we’re not here to talk about docs are we. Dash has another trick up its sleeve. Snippets. That’s right, Dash can manage your snippets. It works a lot like a text expander. Each snippet has an abbreviation and that’s what triggers the snippets. It’s probably best to prefix your abbreviations with something to stop them from coming up when you don’t want them to. I use a semi-colon, but you can use whatever you want.
Once you’ve got the body of your snippet, you can add some extra goodness in. Into your snippet you can add a placeholder, a cursor point, what ever is on your clipboard when the snippet is triggered, and the date or time. Probably the most useful of these is the cursor point. What this will do when the snippet has been entered, it will bring the cursor back to that point. It can be a bit buggy, but it works most of the time.
What should I be snippetifing?
Anything you want. Anything you think you will be able to use again. Literally anything. I have one for a skeleton html page that fires from ;doctype. Or my favourites is ;trans which produces:
How many times have you written that out? Unless you’ve got a snippet for it already, I can imagine that you’ve written it out a lot.
And you don’t have to use Dash. You can use whatever you want. You could Sublime’s built in snippets. Or maybe a service like Kodery or Gists. It’s your workflow, do with it what you wish. But my advice to you is to start sooner rather than later. The sooner you start, the bigger your library will be and the less time you will waste. There’s absolutely no downside. So what are you waiting for?!