One of the features that TextExpander offers is the ability to nest snippets inside of one another. This has a lot of applications, but one of the handiest is the ability to separate commonly-used sections of snippets that are subject to change. Doing so allows you to update a single snippet and have all other snippets that reference that information update automatically.

Plain text replacements

For example, I have a snippet called “Marked Application Name” with a shortcut of “marked_name” assigned to it. I can reference that snippet in other snippets by using %snippet:marked_name%. Thus, when I changed “Marked” to “Marked 2”, I only had to edit one snippet to update all of my other snippets to have the correct application name.

Numeric values

I also keep a snippet for the current price of Marked, as well as snippets that use shell scripts to extrapolate prices from that number based on discounts, etc.. These are just Plain Text snippets containing only numbers and decimals.

Calculations

This snippet allows me to fill in the code for a coupon and the percentage discount it provides, then pulls in the current price of Marked and outputs text with the new price based on the calculation of the price minus the percentage. Note that the snippet type is set to Shell Script.

The script uses bc, a command line calculator built into Unix. Here’s the script as plain text if you want to play with it:

#!/bin/bash

echo -n "The coupon %filltext:name=coupon:width=20% will get you %snippet:marked_name% for $`echo "scale=2;%snippet:marked_price%-(%snippet:marked_price%*0.%filltext:name=discount percent:default=20:width=2%)"|bc|tr -d "\n"` (%filltext:name=discount percent:width=2%% off)."

It outputs:

The coupon MISSEDTHEINTROSALE will get you Marked 2 for $10.50 (25% off).

(Yes, that coupon will work for direct purchases at Marked2App.com)

If you have elements in your snippets that are subject to change, this is a great way to save yourself even more time in the future!