When espanso Breaks on Long Replacement Strings (and How to Fix It)

When espanso Breaks on Long Replacement Strings (and How to Fix It)

Hey friends 👋

Today’s post is a quick one, but it might save you from a few head scratches and keyboard punches if you’re an espanso user who’s been wondering why your juicy long replacement snippets randomly just… don’t show up.

If you’re wondering what Espanso is, check this blog post: Espanso: Because Who Actually Likes Typing Out Their Emails?

TL;DR ☕

  • Long replacement strings (>100 chars) can silently break in espanso
  • This is due to the default clipboard_threshold config
  • You can fix it by setting a higher threshold in default.yml

!TL;DR ☕

If you came for the story, here we go: so, here’s what I ran into…

The Problem: Long Replacements Just Break 🧨

I’ve been using espanso for a while now (it’s a neat little open-source text expander that makes typing repetitive stuff a breeze). All was fine and dandy—until I tried adding a longer replacement string, something like:

- trigger: ":some-long-snippet"
  replace: "Dear passangers, we have good news and bad news. Good news is we are landing. Bad news is we are crash landing!"

And poof—nothing. The replacement just didn’t happen. What’s even worse, it would usually trigger the command prompt in editors (similar to pressing CMD + k or CMD + p).

At first, I thought it was something I’d messed up in the syntax. I double-checked, triple-checked… nope, looked fine.

Then I started wondering if maybe the issue was platform-specific. I’m running the newest version on a up2date Mac. Thought it was some weird key combo or something – but, no.

So yeah, turns out…

There’s a Hardcoded Limit (But You Can Fix It!) 🛠️

After digging around a bit—and with a helpful tip from a fellow redditor—I discovered that espanso has a clipboard_threshold setting buried in the default.yml config file (located at ~/.config/espanso/default.yml).

And it looks like this:

# clipboard_threshold: 100

Yep, it was commented out by default.

So what’s this do? If your replacement string is longer than the threshold (default is 100 characters), espanso silently fails to insert it. No warning. No logs. Nada.


The Fix: Increase the Clipboard Threshold 🙌

To fix this, all you need to do is:

  1. Open your ~/.config/espanso/default.yml
  2. Uncomment or add the clipboard_threshold setting
  3. Set it to something higher, like 500:
clipboard_threshold: 500
  1. Save the file and reload espanso (if it doesn’t reload automatically)
espanso restart

And voilà, your long replacements now work like a charm 🎉

Conclusion

If you’ve hit this issue too, I hope this saves you some time. And if you’re just diving into espanso, maybe take this as a reminder to skim the config docs sooner rather than later 😅

Happy expanding!

Written by Nikola Brežnjak