Add Prefix to Lines
Batch add text to the beginning of each line
Put the same text in front of every line
Editing a long list one line at a time is tedious, and doing it with find and replace requires a regular expression that many people do not remember. Add Prefix to Lines lets you type the text you want at the start, and it attaches it to each line in one go. The prefix can be anything: a bullet, a comment marker, a base URL, a currency symbol or a tag.
How to add a prefix
- Type or paste your lines into the Input Lines box, one item per line. Sample fills in a short shopping list and sets the prefix to a dash and space, Paste takes text from the clipboard, and Clear resets the tool.
- Fill in the Prefix field. The placeholder suggests a greater-than pair followed by a space, but you can enter anything.
- Leave Skip empty lines ticked if blank lines should stay blank; untick it to add the prefix to them too.
- Click Add Prefix.
- Check the result and the Before and After counts, then use Copy or .TXT (prefixed-lines.txt).
Details of the behaviour
- The prefix is inserted exactly as typed. If you want a gap after it, include a trailing space in the field, for example a dash and a space.
- Lines that contain only spaces are treated as empty when Skip empty lines is on, and are passed through unchanged.
- An empty prefix field leaves the text unchanged.
- The summary states the number of lines in the output, which includes any blank lines that were skipped.
Where it saves time
- Turning plain lines into a quoted reply by prefixing each with a greater-than sign.
- Commenting out a block of configuration or code with a hash or double slash.
- Building full links from a list of file names or slugs by putting the domain and path in front.
- Adding a bullet character or a label such as TODO before each item in a list.
Points to remember
The tool works on lines, not on wrapped paragraphs, so a long sentence that appears wrapped in your editor but is really one line only gets one prefix. Indentation is kept: the prefix goes in front of any leading spaces, not after them. To add text at the end of each line as well, use the companion suffix tool. Everything runs in your browser page, and it does not modify your input box, so you can try another prefix on the same list straight away.
Related Tools