Community
    • Login

    Increase by Letters, not just numbers?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    11 Posts 5 Posters 2.2k 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.
    • Moe SkaatoM
      Moe Skaato
      last edited by

      To increase a list of numbers: “Alt-C” and enter numbers.
      How do you do this type of thing for letters?

      A
      B
      C
      D

      or

      a
      b
      c
      d

      Meta ChuhM 1 Reply Last reply Reply Quote 0
      • Meta ChuhM
        Meta Chuh moderator @Moe Skaato
        last edited by

        @Moe-Skaato

        unfortunately this is not possible using the built in column editor.
        only numbers can currently be incremented.

        Moe SkaatoM 1 Reply Last reply Reply Quote 0
        • guy038G
          guy038
          last edited by

          Hello, @Moe-Skaato,

          I do understand your request ! However, when you use the Column Editor to increment numbers, whatever its format, it just increases numbers, with the increment number, till the last line of current file is reached !

          But how do you consider the sequence A B C D... ? I mean, after the upper letter Z do you expect the sequence AA AB AC .... AZ BA BB BC .... BZ ...... ZA ZB ZC ..... ZZ or any other kind of sequence ?

          Or do you only need the sequence A B C.....Z ?

          Best regards,

          guy038

          1 Reply Last reply Reply Quote 2
          • Moe SkaatoM
            Moe Skaato @Meta Chuh
            last edited by Moe Skaato

            @Meta-Chuh , Thanks for the input. That’s what I was thinking. ~: (

            @guy038, I just need:

            A
            B
            C
            D

            as a vertical and “selected” range. It doesn’t have to go all the way to ‘Z’

            1 Reply Last reply Reply Quote 2
            • guy038G
              guy038
              last edited by

              Hi, @moe-skaato and All,

              If you just need to insert the range ABCD, in column, here is a work-around, using regular expressions !

              Let’s suppose you have this text, ( part of N++ license.txt ) Note that I deliberately deleted the leading space !

              ****************** IMPORTANT NOTEPAD++ LICENSE TERMS **********************
              *                                                                         *
              * Copyright (C)2016 Don HO <don.h@free.fr>.  This program is free         *
              * software; you may redistribute and/or modify it under the terms of the  *
              * GNU General Public License as published by the Free Software            *
              * Foundation; Version 2 with the clarifications and exceptions described  *
              * below. This guarantees your right to use, modify, and redistribute      *
              * this software under certain conditions.                                 *
              *                                                                         *
              * Note that we consider an application to constitute a "derivative work"  *
              * for the purpose of this license if it integrates/includes/aggregates    *
              * Notepad++ into a proprietary executable installer, such as those        *
              * produced by InstallShield. Our interpretation applies only to Notepad++ *
              * - we don't speak for other people's GPL works.                          *
              *                                                                         *
              * This program is distributed in the hope that it will be useful, but     *
              * WITHOUT ANY WARRANTY; without even the implied warranty of              *
              * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
              * GNU General Public License for more details.                            *
              *                                                                         *
              ***************************************************************************/
              

              And that you want to insert, in columns, A B C D, at column 35 of each line, from the third line ( Copyright … )

              Then :

              • Place the cursor at the very beginning of line #3 ( Copyright ©2016 Don HO… )

              • Open the Replace dialog ( Ctrl + H )

              • SEARCH (?-s)^(.{34})(.+\R.{34})(.+\R.{34})(.+\R.{34})

              • REPLACE \1A\2B\3C\4D

              • Select the Regular expression search mode

              • Click first on the Find Next button

              • Now, click once on the Replace button

              You should get :

              ****************** IMPORTANT NOTEPAD++ LICENSE TERMS **********************
              *                                                                         *
              * Copyright (C)2016 Don HO <don.h@Afree.fr>.  This program is free         *
              * software; you may redistribute aBnd/or modify it under the terms of the  *
              * GNU General Public License as puCblished by the Free Software            *
              * Foundation; Version 2 with the cDlarifications and exceptions described  *
              * below. This guarantees your right to use, modify, and redistribute      *
              * this software under certain conditions.                                 *
              *                                                                         *
              * Note that we consider an application to constitute a "derivative work"  *
              * for the purpose of this license if it integrates/includes/aggregates    *
              * Notepad++ into a proprietary executable installer, such as those        *
              * produced by InstallShield. Our interpretation applies only to Notepad++ *
              * - we don't speak for other people's GPL works.                          *
              *                                                                         *
              * This program is distributed in the hope that it will be useful, but     *
              * WITHOUT ANY WARRANTY; without even the implied warranty of              *
              * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
              * GNU General Public License for more details.                            *
              *                                                                         *
              ***************************************************************************/
              

              Then , if you click, again, on the Replace button, this time, text is changed into :

              ****************** IMPORTANT NOTEPAD++ LICENSE TERMS **********************
              *                                                                         *
              * Copyright (C)2016 Don HO <don.h@Afree.fr>.  This program is free         *
              * software; you may redistribute aBnd/or modify it under the terms of the  *
              * GNU General Public License as puCblished by the Free Software            *
              * Foundation; Version 2 with the cDlarifications and exceptions described  *
              * below. This guarantees your righAt to use, modify, and redistribute      *
              * this software under certain condBitions.                                 *
              *                                 C                                        *
              * Note that we consider an applicaDtion to constitute a "derivative work"  *
              * for the purpose of this license if it integrates/includes/aggregates    *
              * Notepad++ into a proprietary executable installer, such as those        *
              * produced by InstallShield. Our interpretation applies only to Notepad++ *
              * - we don't speak for other people's GPL works.                          *
              *                                                                         *
              * This program is distributed in the hope that it will be useful, but     *
              * WITHOUT ANY WARRANTY; without even the implied warranty of              *
              * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
              * GNU General Public License for more details.                            *
              *                                                                         *
              ***************************************************************************/
              

              And so on ;-))


              • Notes :

              • To insert the letters at column N, just place the number N-1 in the search regex

              • If you want to use less letters ( for instance A B C ), use the regex S/R

                • SEARCH (?-s)^(.{N-1})(.+\R.{N-1})(.+\R.{N-1})

                • REPLACE \1A\2B\3C

              • On the contrary, if you need more letters ( for instance the range A B C D E ), use the regex S/R :

                • SEARCH (?-s)^(.{N-1})(.+\R.{N-1})(.+\R.{N-1})(.+\R.{N-1})(.+\R.{N-1})

                • REPLACE \1A\2B\3C\4D\5E

              Hope that this work-around will help you, anyway !

              Best regards,

              guy038

              1 Reply Last reply Reply Quote 3
              • Moe SkaatoM
                Moe Skaato
                last edited by

                Wow, I appreciate such a thorough answer, your
                willingness to help and your patience is admirable!

                I’m not a programmer and not familiar with Regex enough to know what all to write out, but I think I could
                follow your instructions fair enough.

                However, I’m not following your example as what I want, even though it may be such.
                The language in the Regex part sounds related, but I’m not seeing anything in the images that looks close enough
                in principle to follow. It’s probably there, I’m just not seeing it.

                So, let me clarify to ensure we are on the same page:

                preset1= “description about preset”
                preset2= “description about preset”
                preset3= “description about preset”
                preset4= “description about preset”
                preset5= “description about preset”
                preset6= “description about preset”
                preset7= “description about preset”
                preset8= “description about preset”
                preset9= “description about preset”
                preset10= “description about preset”
                preset11= “description about preset”
                preset12= “description about preset”

                to something like

                presetA= “description about preset”
                presetB= “description about preset”
                presetC= “description about preset”
                presetD= “description about preset”
                presetE= “description about preset”
                presetF= “description about preset”
                presetG= “description about preset”
                presetH= “description about preset”
                presetI= “description about preset”
                presetJ= “description about preset”
                presetK= “description about preset”
                presetL= “description about preset”

                or something like

                preset1a= “description about preset”
                preset2b= “description about preset”
                preset3c= “description about preset”
                preset4d= “description about preset”
                preset5e= “description about preset”
                preset6f= “description about preset”
                preset7g= “description about preset”
                preset8h= “description about preset”
                preset9i= “description about preset”
                preset10j= “description about preset”
                preset11k= “description about preset”
                preset12l= “description about preset”

                …if the column editor approach was possible it would have been super simple. I would have selected the column of “1-9” > start with “A” > increase by 1.
                That would end in “I” > next select “10-12” > start with “J” > increase by 1. That would end in “K”

                So I guess you are saying, in principle, with your Regex example, I can achieve the same?

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

                  @Moe-Skaato

                  IMO, this kind of thing isn’t practical to do in Notepad++. Oh, I’m sure @guy038 will give you something, but… :)

                  Moe SkaatoM 1 Reply Last reply Reply Quote 0
                  • Moe SkaatoM
                    Moe Skaato @Alan Kilborn
                    last edited by Moe Skaato

                    @Alan-Kilborn, Thanks for suggestion.

                    It is realistic and useful for the specific context I’m using it in, just not a common practice. It is a way to “customize” a preset list for a plug-in.
                    I wouldn’t actually use the replacement where it is, rather at the beginning of the description. This will affect the order of how the presets are
                    executed as well as help group them thematically when viewing/editing the INI file. I just did it that way to make the general idea of what I want
                    easier to visualize so I wouldn’t have to write out a bunch more stuff.

                    It would be a lot less practical to go in and out of 2 different programs to perform that one function.

                    Alan KilbornA 1 Reply Last reply Reply Quote 0
                    • Alan KilbornA
                      Alan Kilborn @Moe Skaato
                      last edited by

                      @Moe-Skaato

                      Don’t misunderstand. I’m not trivializing what you need to do. I’m just saying that I don’t believe you will find what stock Notepad++ provides you up to the task. You could certainly use a scripting plugin to keep a solution entirely within Notepad++.

                      1 Reply Last reply Reply Quote 0
                      • Terry RT
                        Terry R
                        last edited by

                        @Moe-Skaato said:

                        It doesn’t have to go all the way to ‘Z’

                        The statement above, does that mean you ONLY have about (or less than) 25 lines of coding to do. If so, then working with a regex is overkill. Often many minutes can be spent creating (designing) a regex complete with testing. If you only have a small number of lines it makes more sense to just do it manually. That is UNLESS you have to repeat these edits many times in different files.

                        I have also thought about how one might ‘increment’ characters and insert into lines, my suggestion is another method. It would take a few steps, but each is very easy to understand.

                        If I have original data:
                        “dahl”,“buried starship”
                        “dahl”,“clown prince”
                        …
                        “dahl”,“jaguar jewel”
                        …
                        “david”,“body soul”

                        Original after adding line number and 2 #:
                        001##“dahl”,“buried starship”
                        002##“dahl”,“clown prince”
                        …
                        025##“dahl”,“jaguar jewel”
                        …
                        182##“david”,“body soul”

                        Then open a new tab and insert the letters a through z copied the required number of times to equal the original data line numbers and prefixed with line numbers and a single #:
                        001#a
                        002#b
                        003#c
                        …
                        025#y
                        026#z
                        …
                        170#n
                        171#o
                        …
                        182#z

                        Combined original data and the new data and then sorted numerically:
                        001##“dahl”,“buried starship”
                        001#a
                        002##“dahl”,“clown prince”
                        002#b
                        …
                        025##“dahl”,“jaguar jewel”
                        025#y
                        …
                        182##“david”,“body soul”
                        182#z

                        A replace regex:
                        Find what:(?-s)^\d\d\d##(.+\R)\d\d\d#([a-z])\R*
                        Replace with:\2\1

                        The line numbers and the ‘#’ characters are added through the column editor function you have referenced.

                        In your particular example the regex (which I showed just above) would need altering to suit your data, but is easily achievable.

                        Terry

                        1 Reply Last reply Reply Quote 2
                        • guy038G
                          guy038
                          last edited by guy038

                          Hi, @moe-skaato, @alan-kilborn, @terry-r and All,

                          Of course, the fact of inserting letters, only at a specific column could be binding :-(( So, here is a new method, not based on columns ;-))

                          Assuming your text, in a new tab :

                          preset1= “description about preset”
                          preset2= “description about preset”
                          preset3= “description about preset”
                          preset4= “description about preset”
                          preset5= “description about preset”
                          preset6= “description about preset”
                          preset7= “description about preset”
                          preset8= “description about preset”
                          preset9= “description about preset”
                          preset10= “description about preset”
                          preset11= “description about preset”
                          preset12= “description about preset”
                          

                          Now, just append your list of letters, at the end of your text, with one letter per line ! Of course, you need to insert, at least, the 12 first letters, but you may list, for instance, all letters from A to Z

                          Let’s add letters from A to P. So we get the text :

                          preset1= “description about preset”
                          preset2= “description about preset”
                          preset3= “description about preset”
                          preset4= “description about preset”
                          preset5= “description about preset”
                          preset6= “description about preset”
                          preset7= “description about preset”
                          preset8= “description about preset”
                          preset9= “description about preset”
                          preset10= “description about preset”
                          preset11= “description about preset”
                          preset12= “description about preset”
                          A
                          B
                          C
                          D
                          E
                          F
                          G
                          H
                          I
                          J
                          K
                          L
                          M
                          N
                          O
                          P
                          

                          Now, using the regex S/R :

                          • SEARCH (?-s)^(preset)(\d+)(?=(?:.+\R){12}(.))|^(.\R)+.?\Z

                          • REPLACE ?1\1\3

                          You should get, after a click on the Replace All button :

                          presetA= “description about preset”
                          presetB= “description about preset”
                          presetC= “description about preset”
                          presetD= “description about preset”
                          presetE= “description about preset”
                          presetF= “description about preset”
                          presetG= “description about preset”
                          presetH= “description about preset”
                          presetI= “description about preset”
                          presetJ= “description about preset”
                          presetK= “description about preset”
                          presetL= “description about preset”
                          

                          And if you change the Replace regex with :

                          • REPLACE ?1\1\2\3

                          While keeping the Search regex, you’ll obtain :

                          preset1A= “description about preset”
                          preset2B= “description about preset”
                          preset3C= “description about preset”
                          preset4D= “description about preset”
                          preset5E= “description about preset”
                          preset6F= “description about preset”
                          preset7G= “description about preset”
                          preset8H= “description about preset”
                          preset9I= “description about preset”
                          preset10J= “description about preset”
                          preset11K= “description about preset”
                          preset12L= “description about preset”
                          

                          Of course, you can choose any list of letters, in any order and, also, the leading part of each line :

                          For instance, giving the initial text below :

                          preset1= “description about preset”
                          preset2= “description about preset”
                          preset3= “description about preset”
                          preset4= “description about preset”
                          preset5= “description about preset”
                          preset6= “description about preset”
                          preset7= “description about preset”
                          preset8= “description about preset”
                          preset9= “description about preset”
                          preset10= “description about preset”
                          preset11= “description about preset”
                          preset12= “description about preset”
                          z
                          a
                          y
                          b
                          x
                          c
                          w
                          d
                          v
                          e
                          u
                          f
                          t
                          g
                          s
                          h
                          r
                          i
                          q
                          j
                          

                          With the Replace regex, below ( Again, Search regex is not modified )

                          • REPLACE ?1Line #\2\3\t

                          Here is the result :

                          Line #1z	= “description about preset”
                          Line #2a	= “description about preset”
                          Line #3y	= “description about preset”
                          Line #4b	= “description about preset”
                          Line #5x	= “description about preset”
                          Line #6c	= “description about preset”
                          Line #7w	= “description about preset”
                          Line #8d	= “description about preset”
                          Line #9v	= “description about preset”
                          Line #10e	= “description about preset”
                          Line #11u	= “description about preset”
                          Line #12f	= “description about preset”
                          

                          As you can see, the limit is just your imagination. With regular expressions, you can modify text in so many ways ;-))


                          Notes :

                          • The search regex begins with (?-s), an in-line modifier, which tells that the dot ( . ) will match one standard character ( not EOL ones )

                          • Then there are two alternatives :

                            • ^(preset)(\d+)(?=(?:.+\R){12}(.))

                            • ^(.\R)+.?\Z

                          • The first alternative matches, from beginning of line ( ^ ) , the literal sting preset, stored as group 1, followed with a number \d+, stored as group 2 but ONLY IF the look-ahead is true that is to say if it exists 12 non-empty lines, with their EOL characters ( \R ), followed with, at least, one character ( a letter) on the next line, stored as group 3

                          • Of course, in case that your text to re-number contains more or less than 12 lines, just indicate that exact number in the search regex, instead of the number 12 !

                          • The second alternative simply matches the complete list of letters, at the end of your document. So a non-empty list of one-char lines ^(.\R)+, possibly followed with a last char ( .? ) before some possible EOL chars, ending the current file ( assertion \Z )

                          • The replacement regex, for instance ?1Line #\2\3\t, is a conditional replacement, which means that, IF group 1 exists, then it writes, first, the expression Line #, followed with the initial numbers ( group 2 ), followed with the character, taken from the list of letters ( group 3 ) and, finally, a tabulation char ( \t )

                          Best Regards,

                          guy038

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