Snipsy

by dimagious
5
4
3
2
1
Score: 56/100

Description

Snipsy for Obsidian: type a short trigger, get Markdown. Hotstrings with a community package catalog.

Reviews

No reviews yet.

Stats

10
stars
7,894
downloads
0
forks
187
days
0
days
0
days
108
total PRs
0
open PRs
4
closed PRs
104
merged PRs
4
total issues
0
open issues
4
closed issues
340
commits

Latest Version

17 hours ago

Changelog

Added

  • Patterns: regex triggers (B-074, ADR-0008). The new Patterns page (Settings; a page on Obsidian 1.13+, its own tab below it) lists the rules and lets you add, edit, turn off, reorder (drag the handle, Alt+Up and Alt+Down, or the menu) and delete them. The pattern is checked as you type, with a sentence under the field for every refusal and Save disabled until it passes; a Try it field replays a typed line through the real engine and says what fires, which rule or snippet fires first, and when an instant rule fires too early (1/23 gives ½3); rules the guard turned off for the session show as Paused, and an instant rule while Expand while typing is off says it will not fire. The typography set adds 32 rules (fractions after a separator, arrows, ≠, ≤, ≥, ±, … and more, from the Substitutions defaults) in one click. settings.patterns holds rules written as /pattern$/flags (the flag i only, as written) with a replacement that can use {{0}} (whole match), {{1}}..{{9}} and {{name}} for named groups, next to $|, $1..$9 fields, $date, $clipboard. Captured text is inserted last and literally, so a captured $1, $| or {{date}} stays text and field and caret positions account for it. Each rule is instant (tried after every typed character, the match must end at the caret) or separator (tried like a literal trigger, on a separator or on "Expand trigger at cursor"). Literal triggers win over every pattern. Separator rules also run on Tab ("Expand on Tab") and on the Text Snippets alias command, after a literal trigger: with the caret inside a word the rule reads the line up to the end of the word and counts only if its match starts at or before the caret (a match that lies wholly after it is left alone, the rules further down are then not tried either because the first matching rule owns the word, and Tab passes through); instant rules never run there, and with "Expand while typing" off they stop running as you type too. Patterns are then tried strictly top to bottom whatever their mode, the first match wins: a separator rule reads the line before the typed separator, an instant rule the line through it. Patterns also run when the literal lookup came back empty (:(\w+):$ fires on the space after the closing colon), prefix mode does not apply to them, only the last 64 characters of the line are looked at (plus 16 characters of context so \b and lookbehind do not see a false line start), the match must end at the caret, and code, math, frontmatter and non-typing edits are skipped as for any trigger. A pattern expansion is its own undo step (Cmd/Ctrl+Z gives back what was typed) and works with Highlight + Backspace in both modes. Rules in a disabled group are skipped. With Obsidian's auto-pairing on ("Auto-pair brackets": brackets and quotes; "Auto-pair Markdown syntax": *, _ and backtick), an instant rule ending in a paired character (/\(c\)$/i, /\*x\*$/) fires when the closing character is typed, although the editor only steps the caret over the closer it inserted: only a closer the editor just auto-inserted counts (an arrow key or a click onto another ) does not), a typo fixed with Backspace inside the pair does not lose it, and literal snippets and separator rules are not tried on that step. A rule that ends in the opener (/:\($/ to a sad face) runs as the pair is inserted and takes the auto-inserted closer with it in the same undo step, so the text is what the same typing gives with auto-pairing off and one Undo, or Backspace with Highlight on, brings back the pair with the caret inside. A rule written without an id (a hand edit or sync) shows as an error and is kept off, also when it is saved from the editor, until you turn it on. Saved data from this version survives a round trip through 1.8.0.
  • Espanso import: regex: matches become pattern rules (B-074, ADR-0008). The import on the Packages page used to skip every regex: match; now each one is converted and listed in the preview as its own Pattern rules section (pattern, replacement, mode, or the reason it was left out), and Apply writes the snippets and the rules together with one save (a failed save puts both back; the rules go to the end of the list, switched on, in the group named in the import). The conversion: (?P<name> becomes (?<name>; {{name}} in the replacement is the capture of the same name (Espanso has named groups only; a {{1}} or a name that is no group of the regex is refused, because here it would mean a numbered capture or stay literal text); the closing $ is appended when the regex does not end with an unescaped one (\$ is a dollar sign); a leading (?i) becomes the flag i. The rule is imported as Instant, as Espanso fires it, and as After a separator (with a note in the preview) when only the instant limit of one open-ended repeat stops it, as with (\d+)/(\d+). Left out, each with a reason: any other inline flag, Rust class syntax that JavaScript reads differently ([[:alpha:]], nested classes, &&, --, ~~), \p{...}, backreferences, lookahead, nested quantifiers and everything else the Patterns page refuses (with the sentence it shows), a replacement with vars:, a form, a shell, script or choice variable, case propagation, an image, and word, left_word or right_word (a pattern cannot honour them exactly). \w, \d, \b and their negations are Unicode-aware in Espanso and ASCII-based in a pattern, so an imported rule can match differently on text with non-ASCII letters; a leading (?i) folds case the simple way here and the Unicode way in Espanso (rare letters such as ſ and the Kelvin sign differ); and ^ means the start of the line here, the start of Espanso's buffer there. {{ name }} with spaces, {{name.sub}} and any other {{...}} that is not exactly {{name}} of a named group is left out; {{ clipboard }} with spaces now maps to $clipboard like {{clipboard}}, for plain triggers too. A rule with the same pattern and replacement as one you already have is left out as "already there", and rules past the 100 rule limit as "over the 100 rule limit". What an import inserts is what Espanso inserts, or the match is left out with a reason (B-266), for plain triggers and regex matches alike. Text that is plain in Espanso but live syntax here is no longer changed silently: $1 to $9 in the replacement (costs $5, pay $1 on) are stored with the escape \$5 and insert as written (they used to become fields or vanish); plain $|, $date, $time, $filename, $clipboard, {{date}}, {{time}}, {{date:FMT}} and {{time:FMT}} have no escape, so a match that contains one is left out; a \$1 already written with a backslash is left out too, because here the backslash would be eaten. {{clipboard}} or a date variable directly before a letter, digit or _ ({{d}}{{d}}a), or {{clipboard}} directly before a date or time variable ({{clipboard}}{{d}}), would become dead text, so the match is left out ({{d}}{{d}} alone imports as $date$date; {{date}} / {{time}} would end the token, but they render locale digits in some Obsidian languages where Espanso gives ASCII). A lone vars: entry of type clipboard is mapped like {{clipboard}} (plain triggers only), and so is a lone date variable whose only parameter is format (%Y-%m-%d or %H:%M); a date variable with offset, tz or locale is left out (any other parameter is ignored, as Espanso ignores it), and so is one whose name is not a word (empty, my-var, a.b, a²), because Espanso never reads that as a reference; a word is as in Espanso: letters and other alphabetic characters, marks, decimal digits, connector punctuation such as _, and joiners, with Unicode whitespace allowed inside the braces. Any other {{name}} or {{name.sub}} in a plain trigger's replacement is a variable in Espanso, never text (a missing one is an error there, a global_vars: one is a value Snipsy does not read), so the match is left out with uses {{name}}, a variable this match does not declare; on a regex match such a name is a capture group and is checked by the pattern conversion. An undeclared {{clipboard}} still maps to $clipboard: that is a Snipsy convenience, not something Espanso does. \{\{ and \}\} in a replacement are left out (Espanso turns them into plain braces). Espanso's $|$ cursor maps to $|; Espanso removes every $|$ and puts the cursor at the first, so only the first is kept. The reason for a left-out {{date:{{clipboard}}}} quotes the text as written. A pasted Espanso YAML over 2 MiB (the size limit of a package install) is refused with a message before it is parsed.
  • JSON backup includes pattern rules (B-074, ADR-0008). Export JSON in General now also writes your pattern rules, exactly as stored (unknown fields included), and Import JSON previews and applies them: a Pattern rules section lists the rules that will be stored, and the ones left out, each with the sentence the Patterns page shows. Merge appends the rules you do not have yet (same pattern and replacement) after yours and leaves yours untouched; Replace all swaps the whole rule list too, and the Replace hint says how many rules it deletes. A file without rules behaves as before and never touches your rules, and a stored patterns value that is not a list is never overwritten. Every rule goes through the same pattern check as the editor (S-015) and the 100 rule limit, again when you press Apply, with one save for snippets and rules together (a failed save puts both back); a rule without an id is stored switched off. At most 500 entries of a file are looked at, so a hostile file cannot freeze the preview. Older Snipsy versions read the backup as a flat object of strings and refuse a file with an array in it, so the rules travel as one more string entry named snipsy patterns (the rule list as JSON text): 1.7.0 and later list it as a skipped key and import everything else, older ones store it as a snippet that can never fire. A hand-written top-level patterns array is read too; if a file has both, the snipsy patterns entry wins, and a leftover snipsy patterns snippet is never exported as a snippet. The Backup rows and the Patterns page now say so.
  • A support link in the plugin's listing (fundingUrl in manifest.json), pointing at Buy Me a Coffee, as Dashy and Garmy have.

Security

  • S-015: ReDoS guard for patterns, in two parts. A JS regex cannot be interrupted, and a static check over its syntax can stop exponential backtracking but cannot bound polynomial cost (a lookbehind checked at every backtrack step, case folding under i), so the guarantees are split. 1. A static gate against exponential backtracking and against the parser disagreeing with the engine. Every rule goes through one function that checks the pattern with a small parser (not a regex over the regex) before it is compiled, whichever way it got into data.json (editor, import, sync, hand edit), and a rule that fails is disabled alone with its reason. Refused: a missing trailing $, backreferences, lookahead, a lookbehind with a quantifier or with more than 8 characters or groups in all its lookbehinds together, a repeated group whose body has a quantifier or an alternation ((a+)+, (a|aa)*), more than 2 unbounded quantifiers (1 for an instant rule, which runs after every keystroke: the reason says to switch the rule to "After a separator"), too many overlapping optional, ranged or alternating parts (?, {n,m}, (a|b)) next to them (a? x16, (?:a|) x30 or \w{0,10} x5 take 20 ms to minutes), a pattern that can match the empty string, the group names date, time, title and notedate (also when written with escapes: a backslash in a group name is refused), a body over 200 characters, a replacement over 10 000 characters, and more than 100 rules. Unicode property escapes are refused: every \p{...} and \P{...}, in or out of a class, under any flags, with "Unicode property classes like \p{L} aren't supported yet. Use \w or a range such as [а-яё]." V8 compiles one on the first non-Latin-1 exec, during typing, and a count cannot bound it: a single \p{L}{1,4} next to a short tail (\p{L}{1,4}-\d{2}-\d{2}$) took 90-430 ms, depending non-monotonically on the quantifier, the tail and the property. A malformed one (\pL, [\p], \p{RGI_Emoji}) gets the same hint. The u flag is refused; i is the only flag (owner, round 7): under u, V8 compiles adjacent short ranged terms slowly (the checker measured ~38 ms per exec for \S{1,4} x5 plus a tail, and 8.6 s over 100 keystrokes for 100 distinct such rules, none switched off), and only under u. The editor says "Flag u isn't allowed. Use i or none." Without u an emoji is two code units, so an emoji written as plain text (/:smile:$/, /😀x$/) works, and an emoji or any character outside the basic plane inside a class [...] is refused: "Emoji can't go inside [ ] yet. Write them as plain text, or use a group like (?:😀|🙏)." ([^😀] would match each half alone). A match never splits an emoji, and no capture holds half of one (round 8): a match that would start on the low half of a pair is dropped (/(.)x$/ on an emoji followed by x), so is one with a capture the replacement uses that begins with a low half or ends with a high half (/(.)(.)x$/ with {{1}}: without u, ., \S, \W and [^a] take one code unit), a line that ends between the halves of a pair is not matched until the pair is whole, a replacement that itself holds half of an emoji (a hand-edited data.json) is refused when the rule is compiled, and a last check refuses any expansion whose insert holds a lone half or would leave one at the edge of the replaced range. A quantifier right after an emoji (😀+, a😀?b, 😀{2}) is refused, because it would repeat only the low half: "A repeat can't follow an emoji directly. Put the emoji in a group, like (?:😀)+." A repeated group of emoji alternatives ((?:😀|🙏)+) is refused with a hint that does not point at [ ] (which refuses emoji), and an escaped emoji (\😀, which is a backslash before half of it), in or out of a class, is refused. Escapes are an allowlist: only \d \w \s and \b with their negations \D \W \S \B, \n \r \t \f \v, \0 (not before a digit), complete \xHH and \uHHHH (not a surrogate), and escaped symbols are read; legacy octal (\041), \c, an incomplete \x or \u and escaped letters are refused with "The escape \041 isn't supported. Write the character itself, or use \d, \w, \s or \b." (the escape as written), because the engine reads them differently from how they look. The matcher keeps 16 characters of context before its 64-character window, so a lookbehind sees all it needs and a cut line never looks like a line start, and the window never starts inside a surrogate pair. An instant rule is also skipped, without running its regex, unless the typed character (the last code unit) can end a match. 2. A runtime guard for polynomial cost, on the typing path only: each pattern match is timed. A slow sample is run again on the same text (up to 2 more times), because V8 compiles a regex lazily and the first runs of a rule can take a few ms, and only counts if the fastest run is still over 2 ms. Measured without u (Node, fresh process per run, Cyrillic and emoji text): the first exec of 288 accepted shapes made of adjacent short ranged terms (\S{1,4} x5 plus a tail and the like, with and without i) took 12 ms at worst, and 100 distinct rules of the \S{1,4} x5 shape after a separator cost 727 ms over 100 keystrokes, each keystroke held to the 8 ms budget, none switched off. A rule whose first, second or third exec costs more than 50 ms in all (the sum of that run's samples, re-runs included, so two samples of 43.7 and 48.9 ms count as 92.6) is switched off at once, whatever the cause (the page says "Turned off for this session: it took too long to compile."; the console warning says "Switched off: too expensive to compile (N ms)."). V8 compiles on the first runs and again when the string representation of the input changes, which the text alone cannot predict, so cold is decided by the run count only; a later spike on a warm rule, such as a GC pause, never counts. A rule with such a slow keystroke 3 times within its last 50 runs is switched off until the rules change or Obsidian restarts (the page says "Turned off for this session: it was too slow."; the reason is kept in memory, nothing is written to data.json, and one warning goes to the console, "Switched off: slow on this note"), and one keystroke stops trying further rules after 8 ms, re-runs included; how often that happens is counted for the Patterns page too. Saving unrelated settings (the community cache does it after each fetch) no longer resets what the guard learned. Literal snippets are not affected. There is no promise that a pattern runs in under a millisecond: a slow rule can cost a few keystrokes before it is switched off.
  • S-015 on the Espanso import path. Pattern rules from an Espanso file go through the same gate as rules typed on the Patterns page: each is checked with the pattern check at conversion and again, with the replacement limits, when the rules are planned and when Apply writes them (against the list as it is at that moment), and the 100 rule limit counts the rules you already have, so a file with 500 regex: entries or with ReDoS-shaped ones cannot put more than the limit, or an unchecked rule, into the list. The importer converts at most 1000 regex: matches of one file and the preview shows at most 50 rows per list. A stored patterns value that is not a list is never overwritten by an import.

README file from

Github

Snipsy

Downloads Latest release Stars

Type todo and a space, get a task. Snipsy turns short triggers into text as you write in Obsidian, and a regex pattern you add can turn 1/2 and a space into ½. No scripting, and no templates to learn.

Install: Settings → Community plugins → Browse → search for Snipsy. Then open a note, type todo and a space.

Website · Full reference · 2-minute video

Why Snipsy

  • It knows Markdown. Triggers stay as you typed them in code blocks, inline code, math and frontmatter.
  • Only your typing fires it. Paste, undo, another plugin's edit and IME composition expand nothing.
  • It works on your phone. Same snippets, same picker.
  • Regex patterns are checked before they run. A pattern that could backtrack without limit is refused when you write it, and a rule that turns out slow is switched off.

What you can do

Find a snippet when you forget its trigger. Run Snipsy: Insert snippet… to search triggers and replacements, preview the result and insert it. You can give it a hotkey.

Add your own. Select text, run Snipsy: Add snippet from selection and type a trigger. Symbols work too, so -> can become →.

Install a pack. Thirteen packs, one click each: Meetings, Daily Journal, Code Review, Symbols & Math and more. Each pack gets its own group, so you can mute it or delete it whole.

Take an expansion back. Undo removes it in one step. Turn on Highlight expansions and Backspace restores the trigger too (not for a snippet with fields: the caret moves into the first field, so there is no highlight and Backspace is a normal Backspace).

Stop accidental expansions. Mute a group, or turn on prefix mode so only :todo expands and todo stays a word.

Use it on your phone. The same snippets expand as you type, and the same picker opens. Add Snipsy: Insert snippet… to the editor toolbar in Obsidian's settings to open it with one tap.

Patterns

A trigger is a fixed word. A pattern is a regular expression that must end at the caret, so it can match a shape: 1/2, -->, :work:. Add one in Settings → Snipsy → Patterns, or add the typography set there for 32 ready rules (fractions, arrows, ≠, ≤, ≥, ±, …).

Pattern Replacement You type You get
/\b1\/2$/ ½ 1/2 and a space ½
/-->$/ → --> →, at once
/:(\w+):$/ #{{1}} :work: and a space #work

Each rule is Instant (fires as soon as the text matches) or After a separator (fires on a space, Enter or punctuation, so 1/23 can still be typed). {{1}} is what the first group matched, {{name}} a named group. The Try it field in the editor replays a line through the real engine and tells you what fires. Expansion is one undo step, and it stays quiet in code, math and frontmatter like any trigger. The reference has the syntax, the limits and everything that is refused.

Coming from another tool

Text Snippets. Its last release was in May 2022. On the Packages page, press Import under Text Snippets import. Snipsy shows a preview and copies your snippets into their own group, without changing anything in Text Snippets. Its $tb$ tab stops become fields you walk with Tab (a stop glued to a letter or digit cannot be a field, the reference has the details). One difference: Snipsy expands as you type instead of waiting for a key. If you prefer to trigger expansion yourself, bind Expand trigger at cursor to the key you used there.

Espanso. Paste the YAML of a package and name a group. regex: matches become pattern rules. Forms, scripts and other things Snipsy can't represent are skipped and named.

Substitutions. Its rules, like 1/2 into ½, can be written as patterns here, and the typography set is ported from its 32 default rules. There is no importer for its settings yet. Copy a rule by hand and write {{1}} where it used $1.

Other system-wide expanders. Espanso, Raycast, Keyboard Maestro and AutoHotkey work in every app, and Snipsy works only in Obsidian. Pick Snipsy for Markdown awareness and the same snippets on your phone.

What ships with it

Sixteen triggers in one group called Defaults. Type the trigger, then a space.

Trigger Becomes
todo · done - [ ] · - [x]
h1 · h2 · h3 # · ## · ###
bold · italic · code **|** · _|_ · `|`, cursor inside
note a > [!note] callout, cursor on the body line
table a table, cursor in the first cell
today · now 2026-09-28 · 14:05
brb · omw · ty · imo be right back · on my way · thank you · in my opinion

Delete any of them. Settings → Snipsy → Restore default snippets brings back the missing ones.

Placeholders

Placeholder Becomes
$| where the cursor lands, or the last stop when Tab walks fields
$1, $2... fields: Tab jumps from one to the next, Shift+Tab goes back. With only one $1 it is the cursor. From the picker over a selection, $1 takes the selected text
$date · $time today · now
{{date:dddd, D MMMM}} your own Moment.js format
$filename the note's file name, with its extension
$clipboard what is on your clipboard

The reference has the exact rules.

What it does not do

  • JavaScript or dynamic templates: use Templater.
  • Expansion outside Obsidian: use Espanso.
  • Patterns with backreferences, lookahead or Unicode property classes (\p{L}). The reference lists what a pattern cannot be, and why.

Privacy

No analytics, no telemetry, no account. Snipsy goes online only when you open the Packages page, to fetch the catalog from GitHub. Your snippets stay in the plugin's data.json.

Questions

Delete that snippet, switch off the Defaults group, or turn on prefix mode so only :now expands.

: is a separator, so :smile: can't be typed as one word. Settings → Snipsy → Snippets shows a Fix triggers button that renames them to smile after a preview.

Start Obsidian with --ozone-platform=x11. If that fixes it, please report it in an issue with your desktop and input method.

If something is wrong, or missing

Open an issue with what you typed and what you got. The feature list is short on purpose, and the fastest way to change it is to say what you tried to do and could not.

If Snipsy saves you keystrokes, a star on GitHub helps other people find it, and a coffee says thanks.

Also by the author: Dashy, a dashboard inside an Obsidian note, built from seven Markdown blocks, with no JavaScript or Dataview.

Development commands are in the reference.

License

MIT © Dmitriy Yurkin