Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Ignoring empty lines counting

    Help wanted · · · – – – · · ·
    4
    13
    193
    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.
    • Владислав Пестриков
      Владислав Пестриков last edited by

      Hello there!
      Im searching option how to ignore empty lines counting. For example:
      1 | line1
      2 |
      3 | line2

      And i want
      1 | line 1
      1 |
      2 | line2

      is there any function or plugin?
      Thanks!

      Terry R 1 Reply Last reply Reply Quote 0
      • Terry R
        Terry R @Владислав Пестриков last edited by

        @Владислав-Пестриков said in Ignoring empty lines counting:

        Im searching option how to ignore empty lines counting.

        If you are referring to the line numbers in the left margin, then you cannot change that. That’s because a CR and/or LF (line end markings) are what are counted as part of a line. So empty lines will have these and are therefore counted.

        There is a PlugIn called CustomLineNumbers but on quick inspection it does NOT appear to help you.

        If however you want to get a count of the number of lines that contain text that is a different matter. There are methods of doing that, but they will only work at the time they are run, they use “Regular Expressions”.

        So maybe you need to explain a bit more on what exactly you hope to achieve.

        Terry

        Владислав Пестриков 1 Reply Last reply Reply Quote 1
        • Владислав Пестриков
          Владислав Пестриков @Terry R last edited by

          @Terry-R
          Thank you Terry very much for the answering!
          Im trying then create plugin, it code shouldnt be so hard (i am know oop syntax).
          But after opening plugin template i just dont know what to do exactly
          005a7396-24cf-4186-bcb2-40ec67c4b5d2-image.png
          Can you give me please some ideas about that. All that i need its icon switching these types.
          I find no tutorials about NPP API and im so frustrated…
          Thanks in any case Terry.

          Terry R Ekopalypse 2 Replies Last reply Reply Quote 0
          • Terry R
            Terry R @Владислав Пестриков last edited by

            @Владислав-Пестриков said in Ignoring empty lines counting:

            But after opening plugin template i just dont know what to do exactly

            Sorry, I am NOT a programmer.

            Maybe someone else might be able to point you in the right direction.

            Good luck
            Terry

            1 Reply Last reply Reply Quote 0
            • Ekopalypse
              Ekopalypse @Владислав Пестриков last edited by

              @Владислав-Пестриков

              one way would be to get the buffer pointer and do some calculation like splitting its content by end of line characters and checking if a line is “empty”.

              Or you can install the PythonScript plugin via the PluginAdmin and do something like this

                  print(len([line for line in editor.getText().splitlines() if line.strip() != '' ]))
              
              Владислав Пестриков 1 Reply Last reply Reply Quote 2
              • Владислав Пестриков
                Владислав Пестриков @Ekopalypse last edited by Владислав Пестриков

                @Ekopalypse thanks for you answer also!
                I think both of that is counting non-epmty lines, isnt it?
                So it is not i needed.
                Im programming simple script that uses “jump” to line where every line in script is counting.
                For example:
                1|print “Post v1.0”
                2| set bindingRechargingTime
                3| set transportType @flare
                4| jump 23 equal containerN false
                […]
                23| print "Bindin "

                So you can see i can easely find where jump from line 4 goes.

                But if i add some empty lines to make code more readable between 4 and 23:
                4| jump 23 equal containerN false
                5|
                […]
                24| print "Bindin "

                the script beguns incorrect because "print "Bindin " should called instead other line.

                That’s why i want to associate notepad lines counting with that script.
                After work, of course, i should remove empty lines for correct script working.
                That’s why i want.

                Im susessfully download NppPluginTemplate but its extreemly hard to undestand how getting started to work with him. Any suggestions for that?

                Thank you very much for your help.

                PeterJones 1 Reply Last reply Reply Quote 0
                • PeterJones
                  PeterJones @Владислав Пестриков last edited by PeterJones

                  @Владислав-Пестриков said in Ignoring empty lines counting:

                  I think both of that is counting non-epmty lines, isnt it?

                  Did you try it to see?

                  Do you understand that counting non-empty lines is what you appeared to be asking for, especially when you said “how to ignore empty lines counting”?

                  the script beguns incorrect because "print "Bindin " should called instead other line.

                  Why did it magically change frm 23 to 24?

                  After work, of course, i should remove empty lines for correct script working.

                  Why “of course”? How should we know that? Did you tell us that before?

                  In my opinion, you have not successfully communicated your desires in this instance. I really doubt any of us are going to be able to help you until you are able to communicate those desires.

                  Please see the Formatting Forum Posts FAQ, because otherwise, we cannot easily read your example text. Also if 4| isn’t literally part of the text, please don’t include it in your example.

                  Im susessfully download NppPluginTemplate but its extreemly hard to undestand how getting started to work with him. Any suggestions for that?

                  How to Develop A Plugin => this section of the user manual takes you through the four steps (which are also shown in the plugin template) to get to a point where you can compile a plugin. After that, you have to understand enough about programming to make the plugin actually do something useful.

                  Владислав Пестриков 1 Reply Last reply Reply Quote 1
                  • Владислав Пестриков
                    Владислав Пестриков @PeterJones last edited by

                    @PeterJones
                    thanks very much for answering!

                    Did you try it to see?

                    Yes, firstly, @Terry said:

                    If however you want to get a count of the number of lines that contain text that is a different matter.

                    And i answering, that it is not i want.
                    Secondly, @Ekopalupse suggest:

                    print(len([line for line in editor.getText().splitlines() if line.strip() != '' ]))
                    

                    So i installed PythonScript plugin and test it, and if i right, its about non-empty lines to count (that i not need).

                    Do you understand that counting non-empty lines is what you appeared to be asking for, especially when you said “how to ignore empty lines counting”?

                    Im not appeared to counting empty or not lines. I want to change how count npp lines bar what is 1341f2dc-02af-4231-9e94-f79fde12a330-image.png

                    Why did it magically change frm 23 to 24?
                    Why “of course”? How should we know that? Did you tell us that before?
                    In my opinion, you have not successfully communicated your desires in this instance. I really doubt any of us are going to be able to help you until you are able to communicate those desires.

                    ok i must explain it better, my bad.
                    dfc518cc-ad8e-4058-8357-6e5c9b9ca58e-image.png
                    As a left pucture it goes ok for me as programmer that easely find line that provides jump instruction using npp lines counting bar.
                    But after adding temporary empty lines for more code readability that you can see on right side picture npp bar digits increases lines count as it should. But for me it means bar digits is not now associated with code jump command, it brings to another print command because correct print now is 23. This issue hinders only me as programmer because empty lines that i added should be removed after publication.

                    Please see the Formatting Forum Posts FAQ, because otherwise, we cannot easily read your example text. Also if 4| isn’t literally part of the text, please don’t include it in your example.

                    Thanks, now much better.

                    How to Develop A Plugin => this section of the user manual takes you through the four steps (which are also shown in the plugin template) to get to a point where you can compile a plugin. After that, you have to understand enough about programming to make the plugin actually do something useful.

                    I did steps stopping on 3rd step, you can see my answer upper with picture contains cppPluginTemplate. All just i need its menu on task bar swithing these bar styles and directly my function.
                    It is means that if there is not enought plugin template for me i cant create my own plugin?

                    Extreemply thanks for help supporting.

                    Terry R Ekopalypse 2 Replies Last reply Reply Quote 0
                    • Terry R
                      Terry R @Владислав Пестриков last edited by

                      @Владислав-Пестриков said in Ignoring empty lines counting:

                      It is means that if there is not enought plugin template for me i cant create my own plugin?

                      I can see what you require now that you have provided a better example of the issue you have.

                      I had mentioned a plugin called CustomLineNumbers. The website is here.

                      As a suggestion, make contact with the plugin developer. Since they already have the code sorted for some functionality, maybe with a bit of input from you they may be inclined to expand on their plugin. Alternatively you could take the code (assuming it is “public domain”) and create a “fork” implementing additional code to support your need, since you seem to be OK with programming.

                      Of course you should consult with the plugin developer first as it is their code.

                      Terry

                      1 Reply Last reply Reply Quote 2
                      • Ekopalypse
                        Ekopalypse @Владислав Пестриков last edited by

                        @Владислав-Пестриков

                        I understand that you want something like that, right?

                        1a088ec1-46f2-4546-9689-b982a0dc43a0-image.png

                        What do you mean by taskbar? The taskbar is handled by the operating system itself, not Notepad++.
                        And if you mean the toolbar, then you need to provide the information when you get a nppn-tbmodification
                        by sending nppm-addtoolbaricon message.

                        Владислав Пестриков 1 Reply Last reply Reply Quote 2
                        • Владислав Пестриков
                          Владислав Пестриков @Ekopalypse last edited by

                          @Ekopalypse
                          Oh yeah! Give it me please!

                          What do you mean by taskbar? The taskbar is handled by the operating system itself, not Notepad++.
                          And if you mean the toolbar, then you need to provide the information when you get a nppn-tbmodification
                          by sending nppm-addtoolbaricon message.

                          Sorry, language barrier.
                          a5e66104-7193-45a9-8853-cbfc662c3e6c-image.png
                          like these buttons

                          Ekopalypse 1 Reply Last reply Reply Quote 0
                          • Ekopalypse
                            Ekopalypse @Владислав Пестриков last edited by

                            @Владислав-Пестриков

                            Sorry, what do you mean?
                            The code on the right does what your plugin needs to do, and probably more, since this is just a proof of concept.
                            For example, how to deal with line wrapping, hidden/collapsed lines, etc.

                            If it’s how to add an icon to the toolbar, you can see that in the demo code here.

                            Владислав Пестриков 1 Reply Last reply Reply Quote 2
                            • Владислав Пестриков
                              Владислав Пестриков @Ekopalypse last edited by

                              @Ekopalypse
                              Oh! Godness, thanks a lot!
                              I was confused your right side line counting bar is different instead left, i thought it was just a text.

                              Now i write code in python scrypt plugin and if works extreemly fine (without minor issues, but nvm).

                              Interesting that digit style is different. Looks like bar displaying works harder then i thought.

                              Bless you and happy x-mas to you and npp community!

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post
                              Copyright © 2014 NodeBB Forums | Contributors