Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression Notepad increment numbers in every line

I've to add numbers incrementally in the beginning of every line using Notepad++. It is the not the very beginning. But, like

  when ID = '1' then data
  when ID = '2' then data
  when ID = '3' then data
  .
  .
  .
  .
  when ID = '700' then

Is there any way i can increment these numbers by replacing with any expression or is there any inbuilt-notepad functions to do so.

Thanks

like image 427
Rohin Avatar asked Aug 21 '14 14:08

Rohin


People also ask

Can I use RegEx in Notepad?

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.

How do I change line numbers in Notepad++?

You may have Notepad++ Plugin CustomLineNumbers enabled. Disable it or Uncheck setting that shows it as Hexadecimal numbers. And you should have a regular line numbers.


2 Answers

If you want to do this with notepad++ you can do it in the following way.

First you can write all the 700 lines with template text (you can use a Macro or use the Edit -> Column Editor). Once you have written it, put the cursor on the place you want the number, click Shift+Alt and select all the lines:

enter image description here

enter image description hereenter image description here

like image 91
Federico Piazza Avatar answered Sep 17 '22 11:09

Federico Piazza


It's not possible to accomplish this with a regular expression, as you will need to have a counter and make arithmetic operations (such as incrementing by one).

like image 42
Matias Cicero Avatar answered Sep 20 '22 11:09

Matias Cicero