Expanding Snippets Based on the Before and After Characters

What Comes Before: “Expand When”

Say you want a snippet for “-year-old” to expand right next to the number you type so that it looks like this “12-year-old,” but it only expands after a space, so that is looks like this “12 -year-old.”

  1. Click on the snippet group that snippet is in, you will see the Group Settings appear to the right.
  2. Set “Expand when:” to “Any character precedes abbreviation.” if you want snippets to expand next to any possible character, including letters. Select “All but letters and numbers precedes abbreviation” if you want snippets to expand when directly next to punctuation or white space.

That group was likely set to “Whitespace precedes abbreviation” so that the snippet would only expand after a blank space and not directly next to other characters.

Depending on your abbreviations, you may want to create a separate snippet group specifically for these snippets, and leave your other snippets in a group set to “Whitespace precedes abbreviation”

Here are a couple snippets perfect for a group which expands when typed next to any character:
– -year-old
– @companyemail.com
– anything you frequently type after a parenthesis () [] {}

HTML and code snippet groups are also best set to expand next to any character. For this particular case, consider having these groups only expand in a certain app. This way, when writing an email you don’t have < p > < / p > tags suddenly appearing.

Technical Note: TextExpander only sees what you are typing, and cannot always notice the effects of particular keystrokes. For instance, in MacVIM, typing “i” while in navigation mode changes the context and meaning of subsequent keystrokes, but TextExpander cannot detect that, so if you type “iddate” your “ddate” snippet will not expand, unless it is in a group set to expand after “Any character precedes abbreviation”.

What Comes After: Delimiters

Control whether a typed abbreviation will expand based on what character you type right after it. The key you choose to control whether or not expansion happens is the delimiter.

In the case of a snippet like “vark,” you can type out “Aardvark” knowing your snippet won’t expand as long as you don’t press your chosen delimiter key, such as Enter, Tab, or a punctuation key.

Choose one or more keys to act as delimiters in Preferences > Expansion > Set Delimiter. There are several to choose from, select the checkbox next to the delimiter keys you wish to use.

This setting is independent of the Expand when: setting, and unlike it, it is a global, all or nothing, setting.