Skip to main content

Triggers and Matches

Triggers are the keywords you type that get expanded. Matches define what they expand to.

How Expansion Works

Match File Format

Match files are YAML files placed in ~/.config/texpand/matches/. They define your triggers and their replacements.

matches:
- trigger: ":hello"
replace: "Hello World!"

Simple Text Replacement

The most basic match replaces a trigger with static text:

- trigger: ":thanks"
replace: "Thank you for your help!"

Multiple Triggers

A match can have multiple triggers that all expand to the same thing:

- triggers: [":hello", ":hi", ":hey"]
replace: "Greetings!"

Multi-line Replacement

Use YAML's | operator for multi-line expansions:

- trigger: ":sig"
replace: |
Best regards,
John Doe
Engineering Team

Match Options

OptionTypeDefaultDescription
triggerstringSingle trigger keyword
triggersarrayMultiple triggers for same match
replacestringText to replace trigger with
formstringForm layout with [[field]] placeholders
form_fieldsobjectField configuration for forms
varsarrayVariable definitions
force_modestringInjection mode override
propagate_caseboolfalseMatch case of typed trigger
wordboolfalseWord boundary required

Word Boundary Detection

With word: true, the trigger only matches at word boundaries:

- trigger: "ls"
replace: "list"
word: true
  • ls /tmp → matches
  • callsls → does NOT match

Prefix Convention

Triggers typically start with a special character to avoid accidental expansion:

- trigger: ":hello" # colon prefix (recommended)
- trigger: "git!rel" # exclamation separator
- trigger: ";div" # semicolon prefix for code
tip

Using a consistent prefix like : prevents triggers from matching inside normal words.

What's Next

Learn about Match Files and Configuration for organizing your triggers.