Skip to content

Documentation / MeatPad / Snippets, commands and macros

Snippets, commands and macros

Insert reusable text, run reviewed shell transformations and record repeatable editing actions.

MeatPad 0.31.4 · Released 13 October 2026 · Reviewed 20 October 2026

Create and insert a snippet#

  1. Open Settings → Snippets. Select a built-in snippet to inspect its trigger and language scope.
  2. Choose Duplicate as editable copy to customize a built-in, or Add snippet to make a new one.
  3. Fill in Name, Trigger and Body; expand Languages to choose a scope; choose Save. No selected languages means all languages.
  4. Focus an editor and choose Commands → Insert Snippet, then the snippet. You can also expand its trigger with Tab when the trigger matches.
  5. Use Tab / Shift-Tab to move between placeholders and Escape to finish the snippet session.

Snippet bodies support numbered tab stops such as $1, placeholders such as ${1:name} and a final $0 position. Nested placeholders and repeated numbered stops (mirrors) are supported. Escape literal dollar signs, backslashes or closing braces in snippet syntax. Regex transforms such as ${1/…/…/} are not supported. A user copy with the same trigger and language scope can shadow a built-in snippet. Built-ins are read-only; delete your user copy to remove that customization.

Save and run a shell command#

  1. Open Settings → Commands and choose Add command.
  2. Set Name and Script. Choose Input: None, Selection or Document.
  3. Choose Output: Replace Selection, Insert at Caret, New Note or Output Panel. Set a Key Equivalent if needed.
  4. Review the timeout (default 30 seconds), Restricted environment and the Languages disclosure for scope, then choose Save.
  5. Focus an editor and choose your command from the Commands menu. Check the produced text or output panel. Choose Cancel Command to stop an active execution. To test safely, select hello in disposable text and run tr a-z A-Z with Selection input and Replace Selection output; only that selection becomes HELLO.

To run an ad-hoc transformation, choose Commands → Filter Through Command… (⌥⌘R). Selection input with no selection receives the entire document; Replace Selection with no selection replaces the whole document. Commands act on the current selection, not every caret, and only one command runs at a time. Failed commands, stderr or timeout send output to the output panel rather than replacing text; note windows use a new note instead. Commands are real shell scripts: they can read, change or send data according to their contents and your permissions. Restricted environment retains TM_* context plus PATH, HOME, SHELL, LANG and TMPDIR instead of the full inherited environment; it is not a macOS security sandbox. Avoid shortcuts already owned by standard menus; a clash is marked in Settings.

Filter text through a one-off shell command#

  1. Select some disposable text in the focused editor.
  2. Choose Commands → Filter Through Command… (⌥⌘R).
  3. Enter sort -u in Shell command to sort selected lines and remove duplicates, or enter your reviewed transformation.
  4. Choose Input (None, Selection or Document) and Output (Replace Selection, Insert at Caret, New Note or Output Panel).
  5. Choose Run and inspect the result, or Cancel to close without running. The dialog remembers the last command and mode choices.

Selection/Replace Selection without a selection means the entire document. Output Panel opens a new note when run from a note window. The project output panel shows status/output and provides Cancel for a running process and Close output panel. A typed command is trusted by authorship, so review it before pressing Run.

Use editor context in a command script#

Saved commands receive TextMate-style context variables when that context exists. Use them in your shell script with normal shell quoting, and do not assume project-only values exist in a note window.

VariableContext
TM_SELECTED_TEXTCurrent selected text, when present
TM_FILE_PATH / TM_DIRECTORYActive project file and its containing directory
TM_PROJECT_DIRECTORYProject root
TM_LINE_NUMBER / TM_COLUMN_NUMBERCurrent line and column
TM_CURRENT_LINE / TM_CURRENT_WORDText around the caret
TM_MODECurrent language identifier

The command’s Input setting controls standard input separately from these variables. Restricted environment limits inherited environment values while retaining the supported command context; it does not block filesystem or network operations.

Import a bundle and review command trust#

  1. In Snippets or Commands settings choose Import Bundle… and select a TextMate .tmbundle directory. Its Snippets/*.tmSnippet and Commands/*.tmCommand entries are imported when compatible.
  2. Read the import report, including any skipped items. Import adds supported snippets/commands; it does not promise that every bundle feature can be converted.
  3. Inspect every imported command’s script, input and output before running it. Imported commands start untrusted.
  4. On first run, review the confirmation. In Commands settings, right-click a command for Trust or Revoke Trust.

Choose Run Once for a single invocation without saving trust, or Trust and Run to remember it. Authored commands begin trusted. Trust suppresses future confirmation; it does not make a script harmless. Snippet import and command import are not the same as restoring a complete MeatPad library. Themes have their own import control.

Record, replay and save editing actions#

  1. Focus the editor in which you want to record. Choose Commands → Start Recording Macro (⌥⌘M).
  2. Perform the editing sequence you want to repeat.
  3. Choose Stop Recording (the same ⌥⌘M shortcut).
  4. Place the caret at the intended target and choose Replay Last Macro (⇧⌘M). Inspect the result.
  5. Choose Save Last Macro As…, enter a name and save it. Saved macros appear in the Commands menu for later use.

Macros record supported editor key events; mouse actions and shortcuts consumed by menus (such as ⌘D) are not recorded. They are not a recorder for arbitrary app windows, mouse workflows, shell sessions or other applications. Test a macro on disposable text before applying it to valuable work.

MeatPad version 0.31.4 en — Project editor after recording and replaying a comment insertion macro.
Project editor after recording and replaying a comment insertion macro. · MeatPad 0.31.4 · UI: en
Project editor after recording and replaying a comment insertion macro. · MeatPad 0.31.4 · UI: en
Recording transcript

Focus the project editor. Press Command-Option-M to start recording. Type a Review complete comment. Press Command-Option-M to stop. Press Command-Shift-M to replay; verify the comment appears twice.

Related questions

Need a hand?

Contact MeatPad support. Include your app version, macOS version and the steps that led to the problem.