Add prefix to lines
Transformed in your browser · nothing is uploaded
Puts the same text at the front of every line, or at the end, or turns the lines into a bullet list. Blank lines are dropped rather than being given a prefix with nothing after it, and indentation survives; the prefix goes in front of it rather than replacing it.
How to use the add prefix to lines
This is the small piece of plumbing that turns a pasted column into whatever format the next thing wants: a Markdown bullet list, an email reply quoted with >, a SQL IN clause of quoted values, a set of CSS class names. Doing it with find and replace on the line break almost works and then does not: replacing every break with a break plus your prefix misses the first line, and the same trick for a suffix misses the last, because that line has no break after it. An operation that works on lines rather than on the characters between them has no ends to get wrong.
The field keeps exactly what you type, spaces included, and the space is usually the point: - item is a bullet in Markdown and -item is not. To build a quoted list, run an apostrophe as a prefix and again as a suffix, then join the lines with commas. Three lines become 'alpha', 'bravo', 'charlie', which drops straight into a query. Two things to watch: nothing checks whether a prefix is already there, so running it twice gives you two, and blank lines are removed, so a list with deliberate gaps in it comes back closed up.
Questions
They are removed. A prefix with nothing after it is never what anyone wants.
A bullet needs the space: "- item", not "-item". The field keeps exactly what you type.
Run an apostrophe as a prefix, run it again as a suffix, then join the lines with commas.
Yes. The prefix goes in front of the existing indentation rather than replacing it, so pasted code keeps its shape.
Because one end always misses: the first line has no break before it and the last has none after it.
Yes. Nothing checks whether one is already there, so paste the original back in rather than re-running.
Use the number lines tool, which counts as it goes.