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..
Using Regex to find and replace text in Notepad++ In all examples, use select Find and Replace (Ctrl + H) to replace all the matches with the desired string or (no string). And also ensure the 'Regular expression' radio button is set.
If you're using the numeric keypad, you have to turn the "num lock" feature on, but if you use the number keys across the top of the keyboard, all the numbers as well as the symbols above them work just fine for me. As an alternative to Notepad, you could try Wordpad which is much better for word processing anyway.
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-
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With