• Login
Community
  • Login

Add number in each line

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
8 Posts 6 Posters 735 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    Milo Vir
    last edited by Aug 23, 2024, 5:17 PM

    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%
    
    A C 2 Replies Last reply Aug 23, 2024, 5:26 PM Reply Quote 0
    • A
      Alan Kilborn @Milo Vir
      last edited by Aug 23, 2024, 5:26 PM

      @Milo-Vir

      The answer to that is HERE.

      M 1 Reply Last reply Aug 23, 2024, 5:54 PM Reply Quote 0
      • M
        Milo Vir @Alan Kilborn
        last edited by Aug 23, 2024, 5:54 PM

        @Alan-Kilborn

        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.

        M 1 Reply Last reply Aug 23, 2024, 6:28 PM Reply Quote 0
        • M
          mkupper @Milo Vir
          last edited by mkupper Aug 23, 2024, 6:29 PM Aug 23, 2024, 6:28 PM

          @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.

          T 1 Reply Last reply Aug 25, 2024, 4:48 PM Reply Quote 1
          • C
            Coises @Milo Vir
            last edited by Aug 23, 2024, 7:35 PM

            @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.

            1 Reply Last reply Reply Quote 3
            • T
              Thomas Knoefel @mkupper
              last edited by Thomas Knoefel Aug 25, 2024, 4:54 PM Aug 25, 2024, 4:48 PM

              @Milo-Vir
              … or use the MultiReplace Plugin by adding

              Find what: %site1%
              Replace with: set("%site"..CNT.."%")

              and enable ‘Use Variables’ Option

              D 1 Reply Last reply Dec 18, 2024, 4:39 PM Reply Quote 2
              • D
                dr ramaanand @Thomas Knoefel
                last edited by Dec 18, 2024, 4:39 PM

                @Thomas-Knoefel or anyone else, please explain how to use the above RegEx

                A 1 Reply Last reply Dec 18, 2024, 5:16 PM Reply Quote 0
                • A
                  Alan Kilborn @dr ramaanand
                  last edited by Dec 18, 2024, 5:16 PM

                  @dr-ramaanand said in Add number in each line:

                  please explain how to use the above RegEx

                  I think the “explain” part was already done.
                  But it isn’t a “RegEx”; it’s a syntax peculiar to the MutliReplace plugin.

                  1 Reply Last reply Reply Quote 3
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors