• Login
Community
  • Login

how to put numbers every two rows?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
16 Posts 4 Posters 1.3k 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.
  • A
    astrosofista @DimakSerpg
    last edited by astrosofista Feb 16, 2021, 1:48 PM Feb 16, 2021, 1:47 PM

    @DimakSerpg

    Good try! To delete the unwanted numbers, try this new regex

    Search: (?-s)\{\K.*$|\},\K.*$
    Replace: [leave empty]
    

    Put the caret at the very beginning of the document, select just the Regular Expression mode and click on Replace All.

    Have fun!

    D 1 Reply Last reply Feb 16, 2021, 2:06 PM Reply Quote 4
    • D
      DimakSerpg @astrosofista
      last edited by Feb 16, 2021, 2:06 PM

      @astrosofista oh nice, thank you man!

      A 1 Reply Last reply Feb 16, 2021, 2:26 PM Reply Quote 2
      • A
        Alan Kilborn @DimakSerpg
        last edited by Feb 16, 2021, 2:26 PM

        @DimakSerpg

        Of course i can do something like this, but how to delete numbers between rows?

        That wasn’t quite the approach I was thinking of with the column editor number insertion stuff. :-)

        D 1 Reply Last reply Feb 16, 2021, 2:42 PM Reply Quote 1
        • D
          DimakSerpg @Alan Kilborn
          last edited by Feb 16, 2021, 2:42 PM

          @Alan-Kilborn was your method easier or more difficult? :)

          A 1 Reply Last reply Feb 16, 2021, 2:46 PM Reply Quote 0
          • A
            Alan Kilborn @DimakSerpg
            last edited by Feb 16, 2021, 2:46 PM

            @DimakSerpg

            So my method would have been to generate the number list in an empty file, e.g. :

            1
            2
            3
            4
            5
            etc
            708
            

            and then use regex replacement to build the extra text around that.

            but…it seems that you got where you needed to go…so that’s good!

            1 Reply Last reply Reply Quote 3
            • A
              astrosofista @DimakSerpg
              last edited by Feb 16, 2021, 3:15 PM

              Hi @DimakSerpg, All

              If the problems you posted here are common in your daily workload, then I would suggest you to learn scripting.

              Just for the record, the script I spoke about. This demo is in AutoHotkey, but it could be scripted in several other languages. All the text is automatically created and the outcome is placed on the clipboard, ready to be pasted.

              Output  := ""
              Num     := 3 ; replace "3" with the correct number -> 708
              Template = 
              (join`n
              				{
              					"{}" : "{}",
              					"{}" : "{}"
              				},
              
              )
              
              Loop, % Num {
              	Output .= Format("`t`t`t`t" Template, "label", A_Index, "value", A_Index)
              }
              
              MsgBox, % Clipboard := Output
              return
              

              Output:

              			{
              				"label" : "1",
              				"value" : "1"
              			},
              			{
              				"label" : "2",
              				"value" : "2"
              			},
              			{
              				"label" : "3",
              				"value" : "3"
              			},
              

              I hope this simple example will encourage you to learn scripting.

              1 Reply Last reply Reply Quote 3
              • W
                wonkawilly
                last edited by Feb 17, 2021, 1:07 PM

                There is another easy solution without scripting: first you have to join the rows like this:

                {"label" : "1","value" : "1"	},
                {"label" : "2","value" : "2"	},
                {"label" : "3","value" : "3"	},
                

                or even better just create a line like this

                {"label" : "n","value" : "n"	},
                

                and than duplicate it as many times as you need

                {"label" : "","value" : ""	},
                {"label" : "","value" : ""	},
                {"label" : "","value" : ""	},
                {"label" : "","value" : ""	},
                {"label" : "","value" : ""	},
                {"label" : "","value" : ""	},
                

                Than use the column editor that you will find in Edit menu, to add numbers as you want after label and after value.

                {"label" : "1","value" : "1"	},
                {"label" : "2","value" : "2"	},
                {"label" : "3","value" : "3"	},
                {"label" : "4","value" : "4"	},
                {"label" : "5","value" : "5"	},
                {"label" : "6","value" : "6"	},
                ...
                

                Maybe you can even find a plugin to format back the whole code with new lines and indentations with just two clicks : I think JSTool will make the trick.

                Or alternatively you can use find and replace to put back the new lines and the indentations.
                Both ways will work.

                You can operate with both codes more or less the same way :

                case("1  "):         thisLayer.font = font1  ;         break;
                case("2  "):         thisLayer.font = font2  ;         break;
                case("3  "):         thisLayer.font = font3  ;         break;
                case("4  "):         thisLayer.font = font4  ;         break;
                case("5  "):         thisLayer.font = font5  ;         break;
                case("6  "):         thisLayer.font = font6  ;         break;
                case("7  "):         thisLayer.font = font7  ;         break;
                case("8  "):         thisLayer.font = font8  ;         break;
                case("9  "):         thisLayer.font = font9  ;         break;
                case("10 "):         thisLayer.font = font10 ;         break;
                case("11 "):         thisLayer.font = font11 ;         break;
                case("12 "):         thisLayer.font = font12 ;         break;
                case("13 "):         thisLayer.font = font13 ;         break;
                case("14 "):         thisLayer.font = font14 ;         break;
                case("15 "):         thisLayer.font = font15 ;         break;
                case("16 "):         thisLayer.font = font16 ;         break;
                case("17 "):         thisLayer.font = font17 ;         break;
                case("18 "):         thisLayer.font = font18 ;         break;
                case("19 "):         thisLayer.font = font19 ;         break;
                case("20 "):         thisLayer.font = font20 ;         break;
                case("21 "):         thisLayer.font = font21 ;         break;
                case("22 "):         thisLayer.font = font22 ;         break;
                case("23 "):         thisLayer.font = font23 ;         break;
                case("24 "):         thisLayer.font = font24 ;         break;
                case("25 "):         thisLayer.font = font25 ;         break;
                case("26 "):         thisLayer.font = font26 ;         break;
                case("27 "):         thisLayer.font = font27 ;         break;
                case("28 "):         thisLayer.font = font28 ;         break;
                case("29 "):         thisLayer.font = font29 ;         break;
                case("30 "):         thisLayer.font = font30 ;         break;
                case("31 "):         thisLayer.font = font31 ;         break;
                case("32 "):         thisLayer.font = font32 ;         break;
                case("33 "):         thisLayer.font = font33 ;         break;
                case("34 "):         thisLayer.font = font34 ;         break;
                case("35 "):         thisLayer.font = font35 ;         break;
                case("36 "):         thisLayer.font = font36 ;         break;
                case("37 "):         thisLayer.font = font37 ;         break;
                case("38 "):         thisLayer.font = font38 ;         break;
                case("39 "):         thisLayer.font = font39 ;         break;
                case("40 "):         thisLayer.font = font40 ;         break;
                case("41 "):         thisLayer.font = font41 ;         break;
                case("42 "):         thisLayer.font = font42 ;         break;
                case("43 "):         thisLayer.font = font43 ;         break;
                

                with find and replace you can remove the space after the numbers:

                case("1"):         thisLayer.font = font1  ;         break;
                case("2"):         thisLayer.font = font2  ;         break;
                case("3"):         thisLayer.font = font3  ;         break;
                case("4"):         thisLayer.font = font4  ;         break;
                case("5"):         thisLayer.font = font5  ;         break;
                case("6"):         thisLayer.font = font6  ;         break;
                case("7"):         thisLayer.font = font7  ;         break;
                case("8"):         thisLayer.font = font8  ;         break;
                case("9"):         thisLayer.font = font9  ;         break;
                case("10"):         thisLayer.font = font10 ;         break;
                case("11"):         thisLayer.font = font11 ;         break;
                case("12"):         thisLayer.font = font12 ;         break;
                case("13"):         thisLayer.font = font13 ;         break;
                case("14"):         thisLayer.font = font14 ;         break;
                case("15"):         thisLayer.font = font15 ;         break;
                case("16"):         thisLayer.font = font16 ;         break;
                case("17"):         thisLayer.font = font17 ;         break;
                case("18"):         thisLayer.font = font18 ;         break;
                case("19"):         thisLayer.font = font19 ;         break;
                case("20"):         thisLayer.font = font20 ;         break;
                case("21"):         thisLayer.font = font21 ;         break;
                case("22"):         thisLayer.font = font22 ;         break;
                case("23"):         thisLayer.font = font23 ;         break;
                case("24"):         thisLayer.font = font24 ;         break;
                case("25"):         thisLayer.font = font25 ;         break;
                case("26"):         thisLayer.font = font26 ;         break;
                case("27"):         thisLayer.font = font27 ;         break;
                case("28"):         thisLayer.font = font28 ;         break;
                case("29"):         thisLayer.font = font29 ;         break;
                case("30"):         thisLayer.font = font30 ;         break;
                case("31"):         thisLayer.font = font31 ;         break;
                case("32"):         thisLayer.font = font32 ;         break;
                case("33"):         thisLayer.font = font33 ;         break;
                case("34"):         thisLayer.font = font34 ;         break;
                case("35"):         thisLayer.font = font35 ;         break;
                case("36"):         thisLayer.font = font36 ;         break;
                case("37"):         thisLayer.font = font37 ;         break;
                case("38"):         thisLayer.font = font38 ;         break;
                case("39"):         thisLayer.font = font39 ;         break;
                
                

                Then you can format back the text with Plugins > JSTools > JSFormat

                {
                	"label": "789",
                	"value": "789"
                },
                {
                	"label": "790",
                	"value": "790"
                },
                {
                	"label": "791",
                	"value": "791"
                },
                {
                	"label": "792",
                	"value": "792"
                },
                
                case ("1"):
                	thisLayer.font = font1;
                	break;
                case ("2"):
                	thisLayer.font = font2;
                	break;
                case ("3"):
                	thisLayer.font = font3;
                	break;
                case ("4"):
                	thisLayer.font = font4;
                	break;
                case ("5"):
                	thisLayer.font = font5;
                	break;
                case ("6"):
                	thisLayer.font = font6;
                	break;
                case ("7"):
                	thisLayer.font = font7;
                	break;
                case ("8"):
                	thisLayer.font = font8;
                	break;
                case ("9"):
                	thisLayer.font = font9;
                	break;
                case ("10"):
                	thisLayer.font = font10;
                	break;
                

                You will get it done in about 30 seconds of job, but remember to recheck the code for mistakes in case you will correct them doing the procedure again or directly by hands. But I don’t think it will be necessary much more hand corrections.

                Enjoy

                A 1 Reply Last reply Feb 17, 2021, 1:10 PM Reply Quote 3
                • A
                  Alan Kilborn @wonkawilly
                  last edited by Feb 17, 2021, 1:10 PM

                  @wonkawilly

                  Nice posting.
                  That’s the kind of thing I had in mind earlier, but I didn’t elaborate all the details like you did because the OP indicated he already had a solution that worked.
                  Thank you for filling in the gap I left open.

                  W 1 Reply Last reply Feb 17, 2021, 1:15 PM Reply Quote 1
                  • W
                    wonkawilly @Alan Kilborn
                    last edited by Feb 17, 2021, 1:15 PM

                    @Alan-Kilborn In my post there is a little error in the row:

                    {"label" : "n","value" : "n"	},
                    

                    the following is the right one

                    {"label" : "","value" : ""	},
                    

                    Explication:
                    Remove the n before duplicating the row. Sorry I couldn’t correct in time directly into the original post because I had just 180 seconds to make corrections but I hadn’t enough time. Sorry again

                    A 1 Reply Last reply Feb 17, 2021, 1:21 PM Reply Quote 2
                    • A
                      Alan Kilborn @wonkawilly
                      last edited by Feb 17, 2021, 1:21 PM

                      @wonkawilly said in how to put numbers every two rows?:

                      there is a little error in the row

                      It’s OK. BTW I didn’t go step by step through to check for accuracy.
                      It’s enough that you very clearly showed the technique, enough to get someone started down that same path.

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