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:

count_of_red = get_total("red");
count_of_blue = get_total("blue");
count_of_green = get_total("green");

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:

count_of~red = get_total("~red")

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

Enter your email address:

Delivered by FeedBurner

Google Analytics Alternative