Dasch Digresses: My Adventures with Snippets
Industry News

Dasch Digresses: My Adventures with Snippets

July 18, 2018

Meet Dasch

Dasch Fortner is giving you a glimpse into our apprentice program by writing about it bi-weekly. Check back in a few weeks to read more. Dasch is a junior computer science major at Cedarville University, and he isn’t particularly fond of long road trips. He says: “Honestly, if I wasn’t programming for school, I’d be programming for fun.”

Yesterday I thought I might write a post about writing logical fallacies in code.

But after some thought, I don’t know if you can write logical fallacies in code, so I was hindered from writing about it. Instead, I’ve decided to comment on what has become a small, secret obsession of mine. I suppose, then, it’s a secret no longer. 

I’m a fan of the text editor, Vim. Last summer, Philip White (fellow apprentice) got me hooked on the program before warning me it was the gateway to Linux. After half a year using Vim, I obliterated Windows off my laptop and loaded Ubuntu onto it, so I have no reason to contest his claim. Whenever I do a personal or school project, I tend to do it in Vim. I’ve used Atom before, too, but always with a nice Vim plugin.  

I tried to make Vim work with VSCode here at EduSource. When we were setting up our computers my first day, I installed a Vim plugin. It disappointed me a bit. Still hopeful, I installed a different plugin. This one let me down, too. Crestfallen, I decided to give up my dreams of vimnastics and type like a normal person. Unfortunately, my dreams didn’t die so easily, and now I’ve been trying to keep my fingers at home row through another means: user-defined snippets. 

My adventure into snippets began when writing unit tests. Arrow functions may look nice, but they’re awkward to type. After some practice, I could make quick work of these functions, but my digits were dancing all over the keyboard like a bunch of bees. I’m not sure where my desire for snippets originated, but I added a whole arsenal of snippets after I committed to the cause.  

After a couple of additions to a new JSON file (which is how you define snippets in VSCode), I can create an entire unit test file with snippets. I no longer need to type things I don’t want to type. Gradually, I began adding new snippets for every piece of awkward syntax. I can make Javascript objects, for example, just with the prefix ‘obj’. Or, I can make an Angular component class just by typing ‘comp’. 

I also noticed that I can add tab stops in random places to make the snippet more generic. For example, I’ve added snippets to make columns and rows in HTML.  

If you add a cursor location (notice the $2 and $3 in the body), you can easily make the snippet more expandable. In the above example, I rarely want to make a column in isolation, but I frequently want to compose a bunch of rows and columns together. By adding the cursor location within the tag and at the end, I can cycle through those to allow for making columns in and around the one I just added with the snippet.  

So, do all these snippets help me work faster? I don’t know. I’ve noticed I type things a lot quicker, but I don’t know if I program faster. For example, I can whip up a test file that does nothing like lightning, and adding new tests is a breeze. But my speed at adding things to a file doesn’t help me think faster, and so I found myself waiting for a second with an empty snippet thinking about what to put into it.

Unfortunately, VSCode doesn’t have a plugin or any native support to make me think faster. If they add that feature, I’ll switch to that.  

2

Follow Kendra.B on

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *