Skip to content

Snippets

Johan Sanneblad edited this page Aug 18, 2026 · 20 revisions

Snippets are rules that run on everything you paste. Each rule is one line, written like sed:

s/find/replace/flags

Copy any block below, open Settings → Better Paste → Custom processing → Snippets, and press Import snippets.

Remove Perplexity citations

Perplexity has a copy button that strips citations, but it always copies the whole answer. Select part of it with the mouse instead and the citation markers come along. This removes them:

# Remove linked citations like [2](https://source)
s|\[\d+\]\(https?://[^)]*\)||g

# Remove plain citations like [1]
s/\[\d+\]//g

Before:

The sky appears blue because of Rayleigh scattering[1][2]. The same
effect turns sunsets red[3](https://example.com/source).

After:

The sky appears blue because of Rayleigh scattering. The same
effect turns sunsets red.

Keep the two snippets in this order. A linked citation like [3](https://example.com/source) must be removed as a whole. With only the plain rule, [3] disappears and (https://example.com/source) stays in your note.

Perplexity sometimes writes the source name instead of a number, like [wikipedia]. This removes those tags. Put the names you see between the parentheses, separated by |:

# Remove source tags like [wikipedia]
s/\[(wikipedia|reddit|youtube)\]//gi

Collapse blank lines

Text copied from a chat often arrives with runs of blank lines. This folds every run into one:

# Collapse runs of blank lines into one
s/\n(?:[ \t]*\n){2,}/\n\n/g

Want no blank lines at all? Use s/\n(?:[ \t]*\n)+/\n/g instead. Keep in mind that Markdown joins lines without a blank line between them into one paragraph.

Remove trailing spaces

# Remove spaces at line ends
s/[ \t]+$//gm

The m flag makes $ match the end of every line instead of the end of the text.

Writing your own

Rules are JavaScript regular expressions, applied to the whole pasted text from top to bottom.

  • Flags: g replaces every match, i ignores case, m makes ^ and $ work per line.
  • The delimiter after s is your choice. s|http://|https://|g avoids escaping slashes.
  • In the replacement, $1 inserts the first captured group, \n a newline, \t a tab.
  • Lines starting with // are comments.
  • A # line names the snippet when you import.

Test your rules in the Try it box in settings, or in the Better Paste playground on regex101. It opens with the citation pattern, a Perplexity sample, and the flavor set to JavaScript, which is the engine the plugin uses.

Have a snippet others could use? Open an issue and I will add it here.

Clone this wiki locally