The real reason to use snippets

2019/06/01

As a Vim Neovim user, I often indulge in the novelty of browsing plugins. For some reason, I have missed snippets.

If you don’t know what they are, do a quick internet search. Or have a look at Ultisnips. They have an excellent set of screen cast tutorials. It is available for Vim/Neovim. Most modern editors seams to have snippets plugins available.

At first glance, I looks like it is just a way for the user to code faster by using exandable macros. As this might be true, I have come to like it for a different reason.

In my daily programming, I often jump between languages and environments. Sometimes it has been a while since I used the language the last time. Which puts me in a situation where I have to refresh my memmory on the basics of the language. Things like for-loops, or what syntax to write the documentation in. Of course, one can just search on the internet and read up on it in a few minutes. But snippets do the same thing.

For example, if I have forgotten how to write a class in Javascript. I can just search for a class snippet. The snippet will exand to the correct syntax. And I didn’t have to search for something basic like that.

Saves a lot of time and doesn’t break your focus.