Request: Replace various types of types of quotes

One thing I often need is Replaceing proper opening and closing double quotes (like “…”) with the plain straight double quotes ("…"). - A pain to do with a search replace tool!

Therefore it would be great to replace in the given selection all curly quotes with straight ones. But of course this could be generalised to single quotes and for both directions.

Please note that this is different to the current ‘Quotes’ extension, which puts quotes around the selection.

2 Likes

Here ya go:

#popclip
name: Curly Quotes Gone
icon: symbol:quote.opening
javascript: popclip.pasteText(popclip.input.text.replaceAll(/[“”]/g, '"'))

(The above block is an extension snippet - select it to install the extension with PopClip)

CleanShot 2022-04-06 at 08.38.56


Edit: Here’s how you would generalise it to add other types of quotes:

#popclip
name: Curly Quotes Gone 2
icon: symbol:quote.opening
javascript:
  let text = popclip.input.text;
  text = text.replaceAll(/[“”]/g, '"');
  text = text.replaceAll(/[‘’]/g, '\'');
  popclip.pasteText(text);

(note the single quote is escaped with backslash \')

2 Likes

Doesn’t seem to work

I can help but only with more details. Which one did you try? Did you get it installed OK? When you try it what happens?

I selected some text, then tried both, the curly brackets don’t vanish

What app are you trying it in?

Drafts

1 Like

Hmm, that’s weird it should work in Drafts. Send me an email (support@pilotmoon.com) and we can dive into it deeper. A screen recording of the fault would be really useful.

Thanks for this, Nick! (Sorry for getting back with such a delay - didn’t have a chance before.) The snippet works as intended for me (even in Drafts).

Only thing is, I don’t get the icon in the popover, just the text. - We had this before… Is this related to the fact that I’m on Catalina only?

1 Like

Ah great. Yes it’s the Catalina thing because it doesn’t have the apple symbols. You can copy paste the snippet somewhere and change the icon to up to 4 letters

E.g. icon: Q

Would make the icon a letter Q for example.

1 Like