Howard Abrams over at howardism.org has posted a very nice tutorial on yasnippet. I learned a couple of things I didn’t know so you may find it worth a few minutes too.
First off, I was only dimly aware that you can bring up a template for a new snippet with 【Ctrl+c Ctrl+n】. What’s really nice is that the template is a snippet so you can tab through it filling in the fields like any other snippet. I always have to copy an existing snippet into my buffer to get all the boiler plate. This is a lot easier.
More importantly, Abrams shows us how to use yas-expand-snippet
to treat any text as a snippet even if it hasn’t been added to the snippet collection. That may not seem like much but it turns out to be tremendously useful. Abrams gives an interesting use case where he combines auto-insert
with yas-expand-snippet
to fill in the boiler plate at the top of many programming files.
It’s a good tutorial and well worth taking a look at. It shows some of the power of yasnippet that you may not know about.