• Login
Community
  • Login

How to add numbers to a text with notepad?

Scheduled Pinned Locked Moved General Discussion
8 Posts 4 Posters 16.1k 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.
  • O
    oscar remiccc
    last edited by Sep 12, 2018, 1:01 AM

    Hello everyone, friends I am trying to add numbers to the names of a text for example

    jhonn
    james
    karl
    perry
    .
    .
    .
    .
    katy

    to

    1:jhonn
    2:james
    3:karl
    4:perry
    .
    .
    .
    n:katy

    Any friends idea?

    1 Reply Last reply Reply Quote 0
    • T
      Terry R
      last edited by Sep 12, 2018, 1:12 AM

      It looks like you want to put an increasing number sequence to the start of the line.

      If so, then use the Edit, Column Editor function. So put the cursor in the left most position on the first line that requires the number. If you want all lines to have the number, then this would be left most position on the first line. Then select Edit, Column Editor and Text to Insert, type : in the field and click OK
      Then select left most column again (so before the :), Edit, Column Editor and Number to Insert, type 1 in the initial number and increase by 1, then click OK, make sure Dec is selected. You could also have the leading zeros ticked if you like the numbers to look all the same (same number of characters regardless of whether it’s the 1 or 100, so 001 or 100).

      This should achieve what you desire. If you don’t want ALL lines, then you can move the cursor to the first line that needs the number, click once, then hold the Alt key down and move the mouse down to the last line you want numbers in, release and repeat the steps above.

      Terry

      1 Reply Last reply Reply Quote 3
      • O
        oscar remiccc
        last edited by Sep 12, 2018, 1:30 AM

        thanks you

        1 Reply Last reply Reply Quote 0
        • O
          oscar remiccc
          last edited by Sep 12, 2018, 5:44 AM

          Terry, one more query, how can I delete the numbers at the end of a text?
          please

          study20978
          fly20979
          run20980
          swim20981
          learning20982
          todo20983
          no20984

          to

          study
          fly
          run
          swim
          learning
          todo
          no

          1 Reply Last reply Reply Quote 0
          • G
            guy038
            last edited by Sep 12, 2018, 11:32 AM

            Hello, @oscar-remiccc, @Terry-r, and All

            @oscar-remiccc,

            Very easily, with a regular expression S/R ! So,

            • Open the Replace dialog

            • Select the Regular expression search mode

            • Tick, if necessary, the Wrap around option

            SEARCH \d+$

            REPLACE Leave EMPTY

            • Click once, on the Replace All button or repeatedly, on the Replace button

            @Terry-r

            I didn’t know that trick to restrict the range of the column-editor numbering to some lines, with the column mode. Nice :-)) I also tried :

            • A left mouse click, followed by some Ctrl + left mouse click to get zero-length multi-line selections

            • Instead of typing text, open the Column editor and insert numbers.Funny isn’t it ?

            Best Regards,

            guy038

            S 1 Reply Last reply Sep 12, 2018, 12:39 PM Reply Quote 3
            • S
              Scott Sumner @guy038
              last edited by Sep 12, 2018, 12:39 PM

              @guy038 said:

              Instead of typing text, open the Column editor and insert numbers.Funny isn’t it ?

              I don’t know that it is “funny”–it worked as I would expect when I tried it.

              1 Reply Last reply Reply Quote 1
              • G
                guy038
                last edited by guy038 Sep 12, 2018, 1:59 PM Sep 12, 2018, 1:53 PM

                Hi, @scott-sumner and All,

                Scott, it’s just because I was expecting an other output !

                For instance, Let’s suppose the sample 5-lines text, below :

                abc def ghi
                abc def ghi
                abc def ghi
                abc def ghi
                abc def ghi
                
                • Now left click,once, before the letter a of the FIRST line abc def ghi

                • Then, while holding down the Ctrl key, left click right before the letter d, of the FIRST line

                • Again, while holding down the Ctrl key, left click right before the letter g, of the FIRST line

                => So we have 3 cursors, in front of each string abc, def and hij, in the FIRST line

                • Now, open the column Editor ( Alt + C )

                • Select the case Number to insert

                • Type in 1 in the Initial number and Increase by fields

                • Click on the OK button

                => You get the following results :

                1abc 2def 3ghi
                abc def ghi
                abc def ghi
                abc def ghi
                abc def ghi
                

                When I first did this test,…, Hum, I was expecting this text :

                1abc 1def 1ghi
                2abc 2def 2ghi
                3abc 3def 3ghi
                4abc 4def 4ghi
                5abc 5def 5ghi
                

                This is the reason why I’ve thought the normal behaviour weird enough ;-))

                Cheers

                guy038

                S 1 Reply Last reply Sep 12, 2018, 2:23 PM Reply Quote 2
                • S
                  Scott Sumner @guy038
                  last edited by Sep 12, 2018, 2:23 PM

                  @guy038

                  So we have 3 cursors, in front of each string

                  We should note that to get multiple carets (aka cursors) you need Settings (menu) -> Preferences… -> Editing (box on left) -> Multi-Editing Settings -> Enable … ticked…which by default it is not.

                  1 Reply Last reply Reply Quote 2
                  • S Simran Kaur referenced this topic on Jul 10, 2022, 7:14 AM
                  • D deleelee referenced this topic on Jul 11, 2022, 12:50 AM
                  6 out of 8
                  • First post
                    6/8
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors