Community
    • Login

    [IDEA] Highlight all text after X number of characters/words

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    numbercharacterswordscount
    10 Posts 5 Posters 1.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.
    • oroborosO
      oroboros
      last edited by

      I hope it’s ok to post ideas for plugins - if not feel free to delete!

      You know those fields on websites, where you can enter 2000 characters of text and not more?

      My idea for a plugin would provide a simple UI, where you specify 1) the number, 2) whether you’re counting words or characters, and 3) if characters include non-space or not. All text beyond that limit will be in red.

      This would be useful in editing texts down to the proper limit.

      I’m not a dev, but maybe there’s someone who finds this interesting…!

      Alan KilbornA Michael VincentM 2 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @oroboros
        last edited by

        @oroboros

        Doesn’t the View menu’s Summary command provide most of this information? Sample:

        d0db15fa-42c7-4ed7-8bee-45c638ad8b20-image.png

        Additionally, if you put some data you want to validate to a certain length into a new N++ tab and then run the following Find All in Current Document regular expression search on it, it should aid the task, matching only text that is less than or equal to your specified limit:

        find: (?-s)\A.{1,200}

        The above example would be useful for a 200-character limit.
        Lengths up to and including 200 would be matched.

        1 Reply Last reply Reply Quote 4
        • Michael VincentM
          Michael Vincent @oroboros
          last edited by

          @oroboros

          You can already get (some of) this information in the status bar:

          6abac6e3-3546-4b7e-9359-0856e0591d57-image.png

          The “Pos” tells you the position in the file, i.e., number of characters you’ve typed. So it isn’t really a count down, rather a count up and it doesn’t care about word or non-word characters, it just counts every character (including newlines and other such stuff).

          Cheers.

          Alan KilbornA 1 Reply Last reply Reply Quote 1
          • Alan KilbornA
            Alan Kilborn @Michael Vincent
            last edited by Alan Kilborn

            @Michael-Vincent said in [IDEA] Highlight all text after X number of characters/words:

            The “Pos” tells you the position in the file, i.e., number of characters you’ve typed. So it isn’t really a count down, rather a count up and it doesn’t care about word or non-word characters, it just counts every character (including newlines and other such stuff).

            Yes, except it isn’t very good for this purpose if you have multi-byte UTF-8 characters in your data, as it is more of a byte-based thing, than a character-based thing.

            Hmm, thinking about it, I’m not sure how multi-byte characters would interact with the Summary data I showed before. Would take further experimentation…

            1 Reply Last reply Reply Quote 3
            • oroborosO
              oroboros
              last edited by

              I guess my idea was to have a visual representation, where you actually see how many words/chars you’re over as you’re typing, and dwindle your way down til you have no more “red”.

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

                Hi @alan-kilborn and All,

                Alan, you said :

                Hmm, thinking about it, I’m not sure how multi-byte characters would interact with the Summary data I showed before. Would take further experimentation…

                To that purpose, you could look at these two looong posts, written in October 2020 :

                https://community.notepad-plus-plus.org/topic/20218/tests-and-impressions-on-the-view-summary-functionality


                Take your time to fully assimilate all the notions ! And, of course, you can test my different counting regexes, for possible error(s) !

                Just note, Alan, that I haven’t created any issue yet, regarding the summary feature !

                Best Regards,

                guy038

                Alan KilbornA 1 Reply Last reply Reply Quote 3
                • Alan KilbornA
                  Alan Kilborn @guy038
                  last edited by

                  @guy038

                  two looong posts

                  I haven’t created any issue yet!

                  Yes, I remember them now. Thanks for the refresher, though.
                  If you’re going to make issue(s) out of your findings, then there is “no time like the present”!

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

                    @oroboros said in [IDEA] Highlight all text after X number of characters/words:

                    My idea for a plugin would provide a simple UI, where you specify 1) the number, 2) whether you’re counting words or characters, and 3) if characters include non-space or not. All text beyond that limit will be in red.

                    I guess my idea was to have a visual representation, where you actually see how many words/chars you’re over as you’re typing, and dwindle your way down til you have no more “red”.

                    So one thing we do here is try to offer alternatives to help you in what you’re trying to do. Often the alternatives are good in and of themselves, but quite often they aren’t exactly matching the original desire.

                    It’s great to have an “idea for a plugin”, but nobody (but perhaps yourself, if you’re capable) is going to jump on that and create a plugin. It just doesn’t happen that way.

                    And if you think your idea is super, keep in mind that it may be useful to just yourself, or a limited number of other users. Plugin developers or Notepad++ developers aren’t going to implement your idea, because of its limited applicability.

                    Suggest you consider the alternatives presented, or possibly hope for more replies with additional options.

                    oroborosO 1 Reply Last reply Reply Quote 3
                    • oroborosO
                      oroboros @Alan Kilborn
                      last edited by

                      Thanks for this!

                      EkopalypseE 1 Reply Last reply Reply Quote 0
                      • EkopalypseE
                        Ekopalypse @oroboros
                        last edited by

                        @oroboros

                        I can imagine a Python script, must have PythonScript plugin installed, of course, if the UI can be replaced by Npp editor itself. Basically a script that monitors what you type and if the conditions are met, change the colour.

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