Line Prefix & Suffix
Add numbering, prefixes, or suffixes to every line
Use {n} in the prefix or suffix to insert the line number.
Line Prefix & Suffix — what it does
Add text to the start or end of every line, with a placeholder that inserts the line number where you put it, and an option to include or skip empty lines. It is a small transformation that saves a great deal of repetitive editing when a list has to become something else.
Worked example
A column of order IDs with one empty line, wrapped for an SQL IN list with the prefix ' and the suffix ', (Include empty lines left unticked).
Input text
ORD-1042 ORD-1043 ORD-1051 ORD-1052
Output — prefix and suffix applied
'ORD-1042', 'ORD-1043', 'ORD-1051', 'ORD-1052',
The empty line is kept as an empty line rather than removed, and the last line also gets the trailing comma; delete it before pasting into a query.
When this tool helps
- Turning a list of values into quoted, comma-terminated lines for a code array.
- Adding a Markdown bullet or blockquote marker to every line at once.
- Wrapping a list of paths or names in a command prefix for a shell script.
How to use it
- Paste the text.
- Enter a prefix and a suffix.
- Use the line-number placeholder if you need numbering.
- Choose whether empty lines are included, then process.
Accuracy, limits, and good practice
- Prefix and suffix together build a wrapper: quote before and quote-comma after turns any list into a code-ready array body.
- Skipping empty lines keeps stray blank entries from being decorated into meaningless quoted empties.
- For a repeated multi-line transformation, do the prefixing here and finish with the join lines tool to collapse it into one line.
Frequently asked questions
How do I insert the line number?
Use the placeholder in the prefix or suffix; it is replaced with the current line's number as each line is processed.
Can I add different text to different lines?
The same prefix and suffix apply to every line. For varied content, process the groups separately.
Does it trim existing whitespace?
Lines are used as they are, so trim beforehand if the source has ragged indentation you do not want preserved.
Does the {n} counter skip empty lines?
Yes, unless Include empty lines is ticked. With the prefix "{n}. " the four IDs above are numbered 1, 2, 3, 4 and the blank line stays blank; with the option on, the blank line becomes a numbered line of its own ("3. (row 3)" with a suffix of " (row {n})") and the IDs after it shift to 4 and 5. {n} works in the suffix as well as the prefix and may appear more than once.
Are empty lines deleted when the option is off?
No. They are output as empty lines, so the line count stays the same as the input; only the prefix and suffix are withheld. To drop them entirely, run the result through the Join Lines tool with Remove empty lines, or delete them first.
Related tools on this site
- Lorem Ipsum Generator — Generate placeholder paragraphs for layouts and documents
- Text Difference Checker — Compare two texts line by line and highlight changes
- Cron Expression Builder — Build and explain standard five-field cron expressions
Further reading: Cleaning Up Text You Pasted From Somewhere Else
Everything above runs inside this page. Line Prefix & Suffix needs no account, no upload, and no server round trip — close the tab and nothing is left behind.
每行前後綴工具能做什麼
為每一行的開頭或結尾加上文字,並可用佔位符在指定位置插入行號,也能選擇是否處理空行。這是個小小的轉換,但當一份清單必須變成別的東西時,能省下大量重複編輯。
實際範例
一欄訂單編號含一個空行,以前綴 ' 與後綴 ', 包成 SQL 的 IN 清單(包含空行未勾選)。
原文
ORD-1042 ORD-1043 ORD-1051 ORD-1052
加上前後綴後
'ORD-1042', 'ORD-1043', 'ORD-1051', 'ORD-1052',
空行仍以空行保留而不是被去掉,最後一行同樣帶著尾端逗號,貼進 SQL 前要先刪掉。
什麼時候用得上
- 把一串值變成加引號、結尾帶逗號的行,直接組成程式陣列。
- 一次為每一行加上 Markdown 的項目符號或引用符號。
- 為 shell 腳本把一串路徑或名稱套上命令前綴。
使用步驟
- 貼上文字。
- 輸入前綴與後綴。
- 需要編號時使用行號佔位符。
- 選擇是否包含空行,然後執行。
精確度、限制與實務建議
- 前綴與後綴合起來就是包裝:前加引號、後加引號與逗號,任何清單都能變成可用的陣列內容。
- 略過空行可避免多餘的空白項被裝飾成毫無意義的空引號。
- 多行轉換做完後,可再用合併行工具收成一行,兩個工具串起來很順。
常見問題
怎麼插入行號?
在前綴或後綴中使用佔位符,處理每一行時會替換成該行的號碼。
不同行可以加不同文字嗎?
同一組前後綴會套用到每一行。內容需要不同時,請分組分次處理。
會修剪既有空白嗎?
各行原樣使用,若來源縮排參差且不想保留,請先自行修剪。
{n} 計數會跳過空行嗎?
會,只要沒勾選包含空行。前綴為「{n}. 」時,上面四個編號會得到 1、2、3、4,空行維持空白;勾選後空行會自己變成一行有編號的內容(後綴為「 (row {n})」時是「3. (row 3)」),後面的編號則順延成 4 與 5。{n} 在後綴裡同樣有效,也可以重複多次。
選項關閉時空行會被刪掉嗎?
不會,空行仍以空行保留,行數與原文相同,只是不加前後綴。想整個丟掉空行,可以把產生的文字再經過合併文字行工具並勾選去空行,或是先手動刪掉。
本站相關工具
- Lorem Ipsum 產生器 — 為版面與文件產生佔位段落
- 文字差異比較 — 逐行比較兩段文字並標示變更
- Cron 表達式生成器 — 建立並解釋標準五欄 Cron 表達式
延伸閱讀: 清理從別處貼上的文字
以上步驟全部在這個頁面內完成,每行前後綴工具 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。