How to add numbers to a text with notepad?



  • 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?



  • 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



  • thanks you



  • 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



  • 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



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



  • 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



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


Log in to reply