N. Chamaa
N. Chamaa

Reputation: 1577

Line's number using regex in Notepad++?

Is it possible to get the line's number using regex in Notepad++;

what I want to do, is replacing:

line1
line2
line3
etc..

with

1-line1
2-line2
3-line3
etc..

Upvotes: 23

Views: 27754

Answers (2)

Jim
Jim

Reputation: 291

Older question, but I had this question myself today and found another answer than those presented already.

Column Editor (Alt + C) provides a way to insert numbering. Options exist to choose the starting number, interval, and how often each number should be repeated. Place the cursor on the first position of the first line and increment by one to mimic the actual line numbers.

Upvotes: 29

Philipp
Philipp

Reputation: 69663

Notepad++ can do that by using the TextFX plugin. Select the lines and then select TextFX->TextFX Tools->Insert Line Numbers from the menu bar.

This will add line-numbers padded to 8 places with leading zeros. To get them in the form described in your question, you can use a regex-replace with these values:

search for: ^0+([0-9]+)\s

replace with: line\1-

Upvotes: 28

Related Questions