iToolsPro

文本行号

批量添加自定义格式行号(如 01. / | 1 |),或一键去除复制代码自带的冗余行号

输入文本
操作模式
起始 步长 位数(0=自动)
转换结果
提示:处理在本地完成,数据不会上传。移除行号只删行号本身,保留行首缩进、空格与 tab。
01. · 1: · | 1 | · #1

行号,想加就加想删就删

用自定义模板给每行批量添加行号,或一键去除复制代码时带出的冗余行号,本地处理零上传。

100% 本地处理 · 数据不上传

核心特性

自定义模板
用 {n} 占位符自由定义格式,如 {n}. 、| {n} | 、#{n} ,带起始号、步长与零填充。
智能去号
自动识别 12. 、12) 、| 1 | 、#12 、[1] 等常见行号格式,一键清除,不误伤正文。
批量处理
整段粘贴多行文本,空行可跳过编号,一次完成所有行的行号处理。

适用场景

📝 技术文档 💻 代码片段 📜 日志输出 📋 论坛代码去号

文本行号工具指南Line Numbering Guide

了解行号模板、去号规则与常见问题。Line-number templates, stripping rules, and answers to common questions.

功能说明What It Does

文本行号工具支持两种操作:为每行文本添加自定义格式的行号(通过 {n} 占位符控制编号位置与格式),以及识别并去除行首常见的行号(如 12. 、12) 、| 1 | 、#12 等)。

This tool does two things: add custom line numbers to every line (using the {n} placeholder for position and format), and detect & strip common leading line numbers (like 12. , 12) , | 1 | , #12).

全部在浏览器本地完成,数据不会上传。

Everything runs locally in your browser - nothing is uploaded.

行号模板Line-number templates

模板用 {n} 表示当前行号,其余字符原样输出。如 {n}. 生成 1. 、2. ;| {n} | 生成 | 1 |;#{n} 生成 #1。可设置起始编号、步长与零填充位数(如 2 位生成 01、02)。

Use {n} as the line-number placeholder; everything else is literal. E.g. {n}. makes 1. 、2. ;| {n} | makes | 1 |;#{n} makes #1. You can set the start value, step and zero-padding width (e.g. width 2 makes 01, 02).

默认跳过空行,保持文档空行结构不被编号。

Blank lines are skipped by default so the document's empty lines stay unnumbered.

使用步骤How to Use

  1. 选择「添加行号」或「移除行号」模式。Choose "Add line numbers" or "Remove line numbers".
  2. 添加时设置模板、起始号、步长与位数。When adding, set the template, start, step and width.
  3. 粘贴文本,点击「转换」并复制结果。Paste text, click "Convert" and copy the result.

常见问题FAQ

Q1. 移除行号会误删正文吗?Q1. Could stripping remove content?

只会去除行首「数字+分隔符」形态的格式,纯文本与代码不受影响;少数以数字+点开头的句子会被当作行号,请人工确认。Only leading "number + separator" patterns are removed; plain text and code are untouched. Sentences that happen to start with a number and a dot may be treated as line numbers - please double-check.

Q2. 自定义模板怎么写?Q2. How do I write a custom template?

用 {n} 代表行号,其余字符照抄,如 "行{n}: " 生成 "行1: "。模板会在每行开头插入。Use {n} for the number and keep everything else literal, e.g. "Line {n}: " makes "Line 1: ". The template is prepended to each line.

Q3. 空行会编号吗?Q3. Are blank lines numbered?

默认不编号,保持空行空白;取消「空行不加号」后空行也会参与编号。By default blank lines stay blank; uncheck "skip blank lines" to number them too.