Docs menuVariables

// docs · using snipstack

Variables

The {{name}} syntax, defaults, remembered values and the fill form.

Syntax

Wrap a name in double braces:

ssh {{user}}@{{host}} -p {{port}}
  • A name starts with a letter or an underscore, followed by letters, digits, underscores or hyphens: {{host}}, {{db_name}}, {{api-key}}.
  • Spaces inside the braces are ignored: {{ host }} is the same variable as {{host}}.
  • Anything else is plain text and is copied as written, for example {{1x}} or {{a b}}.

There is no default-value syntax inside the braces, no escaping and no filters. Defaults are set in the Variables panel instead.

The Variables panel

Every variable in a snippet gets one row in the Variables panel, shared by all its fragments, in the order the names first appear. Each row has:

  • Default: used when you leave the field alone. Empty means no default.
  • Description: a note on what the value is for.

Use Edit default and Edit description in the row’s menu, or the palette action Edit variable defaults. A default can be up to 10,000 characters, a description up to 5,000.

If you delete a placeholder, its row is hidden. Type it again and the old default, description and remembered value come back.

Filling in and copying

Copy rendered (Cmd+Option+C or Ctrl+Alt+C) or Fill variables & copy (Option+Enter or Alt+Enter) opens Fill in variables. It lists only the variables the current fragment uses, with a live preview.

  • Each field starts with the value you used last time, or else the default.
  • Enter or Cmd+Enter or Ctrl+Enter copies the result. Esc closes the form.
  • The copy button reads Copy command for command snippets and Copy otherwise.

How a value is chosen

For each variable, Snipstack uses the first of:

  1. what you typed in the form;
  2. the remembered value from last time;
  3. the default, if it is not empty.

A field left empty (one you cleared, or one with no remembered value and no default) is copied as an empty string.

Values are inserted exactly as typed, in one pass: $1 stays $1, and a value that itself contains {{x}} is not filled in again.

Remembered values

Remember these values for next time is ticked by default. Snipstack then saves the value of every field (including ones you left as they were, and empty ones) and fills them in next time. A remembered value, even an empty one, is used before the default.

Remembered values are stored in your library. If you sync, they are synced to your database like the rest of the snippet. Exports leave them out unless you tick Include remembered values. Untick Remember these values for next time before you type anything secret: unticking it stops new values being saved, but does not erase a value already remembered, and the app currently has no way to clear one.

In the quick search window, Enter copies straight away when a snippet has no variables, or when every variable already has a remembered value or a default. Otherwise it opens the fill form. Option+Enter or Alt+Enter always opens the form. See Quick search window.

Limits

The filled-in result can be up to 2,000,000 characters (“Rendered snippet exceeds 2000000 characters”).