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.
    • Milo VirM
      Milo Vir
      last edited by

      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%
      
      Alan KilbornA CoisesC 2 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Milo Vir
        last edited by

        @Milo-Vir

        The answer to that is HERE.

        Milo VirM 1 Reply Last reply Reply Quote 0
        • Milo VirM
          Milo Vir @Alan Kilborn
          last edited by

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

          mkupperM 1 Reply Last reply Reply Quote 0
          • mkupperM
            mkupper @Milo Vir
            last edited by mkupper

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

            Thomas KnoefelT 1 Reply Last reply Reply Quote 1
            • CoisesC
              Coises @Milo Vir
              last edited by

              @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
              • Thomas KnoefelT
                Thomas Knoefel @mkupper
                last edited by Thomas Knoefel

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

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

                and enable ‘Use Variables’ Option

                dr ramaanandD 1 Reply Last reply Reply Quote 2
                • dr ramaanandD
                  dr ramaanand @Thomas Knoefel
                  last edited by

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

                  Alan KilbornA 1 Reply Last reply Reply Quote 0
                  • Alan KilbornA
                    Alan Kilborn @dr ramaanand
                    last edited by

                    @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