Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Renumber SelectionNew to Visual Studio Code? Get it now.
Renumber Selection

Renumber Selection

Gruntfuggly

|
1,602 installs
| (2) | Free
Renumbers the lines in the selected text
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Renumber Selection

Simply renumbers lines in the selection. Finds the first number in each line and replaces it with a new number starting from 1.

Examples:

Before After
3 One
4 Two
2 Three
1 One
2 Two
3 Three
One 1!
Two 1!
Three 1!
One 1!
Two 2!
Three 3!
2
Red
3
Green
2
1
Red
2
Green
3
1.2
1.3
1.5
1.2
2.3
3.5
REQ001 - do stuff
REQ001 - more stuff
REQ512 - other stuff
REQ001 - do stuff
REQ002 - more stuff
REQ003 - other stuff

Configuration

renumber-selection.startValue can be used to start from a different number.

renumber-selection.increment can be used to change the increment.

renumber-selection.regex can be used to adjust the pattern for matching lines with numbers.

Note: The regex must contain at least two capture groups. The first should match everything before the 'number' and the second should match the 'number' itself, or watch you want to replace with the incrementing counter. The default regex preserves decimal parts of the number.

renumber-selection.highlightChanges can be set to false to disable highlighting the replaced numbers

renumber-selection.highlightDark can be used to change the highlight (for dark themes)

renumber-selection.highlightLight can be used to change the highlight (for light themes)

renumber-selection.highlightRulerColour can be used to change the colour of the ruler indications

renumber-selection.highlightRulerLane can be used to change the ruler lane

Note: The highlight uses CSS outlines. So valid values should include a style (e.g. dashed, dotted, etc. ), a width (e.g. 1px) and a colour. E.g. "solid 2px red"

Ignoring comments

If you have commented lines which would normally match the regex, you can ignoring them by modifying the regex to include the comment character. For example, to ignore commented lines in markdown, change the regex to: "^([^#]*?)(\\d+)(\\.\\d+)?"

Installing

You can install the latest version of the extension via the Visual Studio Marketplace here.

Alternatively, open Visual Studio code, press Ctrl+P or Cmd+P and type:

> ext install renumber-selection

Source Code

The source code is available on GitHub here.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft