Add number in each line
-
I have the following data in a text file
%site1% %site1% %site1%
Numbers 1 to 463 replace all.
How to change it to%site1% %site2% %site3%
-
-
Thank you for the response. I’ve read in the FAQ in the section Add hardline numbers to the current file. I’ve tried without success. Can you tell me the right code for my problem?
Every bit of your help is valuable. Thank You.
-
@Milo-Vir said in Add number in each line:
Thank you for the response. I’ve read in the FAQ in the section Add hardline numbers to the current file. I’ve tried without success. Can you tell me the right code for my problem?
Every bit of your help is valuable. Thank You.
Exactly what did you try? The
ADD HARD LINE NUMBERS TO THE CURRENT FILE
section of (https://community.notepad-plus-plus.org/topic/23170/faq-can-i-do-a-mathematical-replacement/) offers several suggestions. Keep in mind that at the top of that page it says:In Short: No
Notepad++ itself doesn’t do math on the text during search-and-replace. That is not what text editors are designed to do.We can help you better if you explain what you attempted and how it failed.
-
@Milo-Vir said in Add number in each line:
I have the following data in a text file
%site1% %site1% %site1%
Numbers 1 to 463 replace all.
How to change it to%site1% %site2% %site3%
Click to place the cursor just to the left of the 1 on the first line (between the e and the 1).
Scroll to the end of the file using the scroll bar or the mouse wheel (do not use the keyboard).
Hold down the Shift key and the Alt key, and while holding those, click just to the right of the 1 on the last line. You’ll see that you have a rectangular selection encompassing the 1s, and nothing else.
From the main menu, Select Edit | Column Editor….
Click the radio button labeled Number to Insert, then fill in:
Initial number:1
Increase by:1
Repeat:1
Leading: None
Format: Dec
and click OK.You’ll see that you have what you wanted, except that there will be excess spaces after the numbers that are fewer than three digits. Use the same technique as above (click, then Shift+Alt+click) to make a rectangular selection surrounding the two spaces after the numbers 1 to 9, and press the Delete key to remove them.
Finally, make a rectangular selection around the single spaces after the numbers from 10 to 99 and delete those.
-
@Milo-Vir
… or use the MultiReplace Plugin by addingFind what:
%site1%
Replace with:set("%site"..CNT.."%")
and enable ‘Use Variables’ Option