Skip to main content

C'est la Z

Using Emacs 46 Auto Yasnippets

The other day I discovered auto-yasnippet, another great package by Oleh Krehel or abo-abo.

It looks like it's going to be a great way to solve a particular problem that come up now and again.

There are plenty of times when I want to create a number of similar but slightly different blocks of text. The example on the project site is:

You could use multiple cursors, a macro, or other methods to put in the common text but you still have to deal with the parts of each line that are unique, the red, green, and blue.

You could use a yasnippet but it's unlikely that you'll have a snippet for every occasion. This is where auto-yasnippet comes in. You would write the first line but add a tilda as a placeholder:

and then invoke aya-create. This will get rid of the tildas and create the auto-snippet. Then when you run aya-expand it will put in the snippet with the tilda locations as placeholders.

Very cool.

Check out the video:

comments powered by Disqus