https://github.com/anders-liu/vscode-insert-line-number
Insert line numbers to selected lines or the whole document.
https://github.com/anders-liu/vscode-insert-line-number
vscode-extensions
Last synced: 5 months ago
JSON representation
Insert line numbers to selected lines or the whole document.
- Host: GitHub
- URL: https://github.com/anders-liu/vscode-insert-line-number
- Owner: anders-liu
- License: mit
- Created: 2019-01-01T22:55:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-08-24T05:31:05.000Z (10 months ago)
- Last Synced: 2025-08-24T05:59:09.565Z (10 months ago)
- Topics: vscode-extensions
- Language: TypeScript
- Size: 222 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Insert Line Number
This extension is used to insert line number to a text document which is being edited.
> *Note*,
> This extensions inserts real pure text-based line numbers to each line,
> so it's typically used for code samples _in docs or comments_ for easily indicating the metioned
> lines; it _isn't_ suitable for real code file.

### Support
If you find this extension helpful, you can [buy me a coffee](https://www.buymeacoffee.com/andersliu).

## Features
The line numbers can be inserted to selected lines or the whole document if no any selected lines.
User can select different formats among multiple predefined formats, which can be defined in settings.
## Extension Settings
### `InsertLineNumber.formats`
`InsertLineNumber.formats` is an array of `InsertLineNumberConfig.Format` objects, which have the following properties:
----
#### Property: `start`
Line number of the first line.
##### Default value: `1`
##### Type: `"current" | number`
- `"current"`: Starts from the real current line number.
For example, user selects line 10-15 in the editor,
line numbers 10-15 will be inserted to these lines.
- `number`: Starts from the given number.
For example, when the 'start' is set to 1, and
user selects line 10-15 in the editor,
line number 1-6 will be inserted to these lines.
----
#### Property: `align`
Alignment of the line number.
> *Note*,
> The alignment only apply to the formatted number, no matter the perfix and suffix.
> For example, when prefix is 'C_' and suffix is ':', the result may be 'C_1 :' or 'C_12 :'.
##### Default value: `"left"`
##### Type: `"left" | "right"`
- `"left"`: Align to left.
- `"right"`: Align to right.
----
#### Property: `padding`
Padding char to satisfy padding to the width.
##### Default value: `"space"`
##### Type: `"space" | "zero"`
- `"space"`: Pad line numbers with whitespaces.
- `"zero"`: Pad line numbers with 0.
----
#### Property: `width`
Width of each line number.
> *Note*,
> if a line number were longer than the specified width,
> it won't be truncated.
##### Default value: `"normal"`
##### Type: `"normal" | "alignToLast" | number`
`"normal"`: No padding, keep the line numbers as-is.
`"alignToLast"`: Pad the line numbers to the last (longest) one.
`number`: Pad the line numbers to the given width.
----
#### Property: `prefix`
Perfix would be inserted before the formatted line number.
##### Default value: `""`
##### Type: `string`
----
#### Property: `suffix`
Suffix would be inserted after the formatted line number.
##### Default value: `": "`
##### Type: `string`
**Enjoy!**