0

I often have some text block on a website a PDF file, etc. that I want to add email / markdown style citation to.

So for example I want to turn this:

This is a quote that possible is very long and / or spans multiple lines.

Blablabla […]

And another line.

Into this:

> This is a quote that possible is very long and / or spans multiple lines.
> 
> Blablabla […]
> 
> And another line.

What is a faster way to do this than manually adding > in front of every line?

4
  • It probably depends on the specific implementation - on here you would just select your text & hit ctrl/q. Having said that, web apps are off-topic on this stack - voting to migrate [though you will have to add more detail to avoid the migration simply being rejected]
    – Tetsujin
    Aug 10, 2019 at 8:57
  • That Ctrl-Q function is exactly what I need, but I would like to have it as a standalone tool. Maybe I should ask on softwarerecs.se. Aug 10, 2019 at 9:03
  • This could probably be achieved in AutoHotkey. You select the text, then press a hotkey which copies the text to clipboard, does a search for line ending and inserts the > after each, puts it back in the clipboard and pasted it back into your application. Might have a go later. It would mean another small program constantly running on your computer, but you can set up all sorts of hot keys to insert bits of text or do random things.
    – Mokubai
    Aug 10, 2019 at 9:11
  • On which platform? On anything vaguely Unix-y, sed 's/^/> /'; but of course, ultimately, Emacs.
    – tripleee
    Aug 10, 2019 at 10:01

1 Answer 1

1

I wrote a small shell script to solve the problem:

#!/bin/sh
CLIPBOARD=`xclip -selection clipboard -o`
MODDED_CLIPBOARD=`echo "$CLIPBOARD" | sed 's/^/> /'`
echo "$MODDED_CLIPBOARD" | xclip -selection clipboard -i

It reads the clipboard, adds > in front of every line and puts the result back into the clipboard.

Of course with files it's even easier:

sed 's/^/> /' filename

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .