Community
    • Login

    Need a copy of the red marked regions, after a "Mark All" operation

    Scheduled Pinned Locked Moved General Discussion
    13 Posts 4 Posters 1.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.
    • Alan KilbornA
      Alan Kilborn @Ryszard Adamus
      last edited by

      @Ryszard-Adamus

      So are you looking for a workaround, or just complaining. I call it complaining because if you are making a feature request you are doing it in the wrong place; it belongs where CLICKING HERE will direct you.

      But someone beat you to it: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/6095

      Ryszard AdamusR 1 Reply Last reply Reply Quote 2
      • PeterJonesP
        PeterJones
        last edited by PeterJones

        @Ryszard-Adamus ,

        Hmm… I thought someone else asked this recently.

        Ah, no, a 3-year-old thread had recent activity, though it wasn’t focused on the copying-of-marked text portion.

        However, @Scott-Sumner’s PythonScript code from that thread may help. (He called the marked text “redmarked” to distinguish it from bookmarked text, but I think it will do what you describe, based on the immediate context around that script.)

        (I thought there was something else similar from more recently, but I’m not immediately finding it)

        If that’s not sufficient for you, you might be able to explain what’s not enough about that, and someone here might come up with a tweak or alternative. I was about to point you to the feature-request FAQ, but @Alan-Kilborn beat me to it. :-)

        Ryszard AdamusR 1 Reply Last reply Reply Quote 2
        • Ryszard AdamusR
          Ryszard Adamus @Alan Kilborn
          last edited by

          @Alan-Kilborn Sorry, I have found other similar request in this section but it was already closed. So i just write new.
          There is no solution under link You have provided. Requesting or complaining can look very similar …

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

            @Ryszard-Adamus said in Need a copy marked lines feature:

            Requesting or complaining can look very similar

            Yes, but requesting right here does you no good so it is complaining by default.
            If you really care, you should maybe add to the github discussion and say “YEAH, I really want this feature, too!”

            1 Reply Last reply Reply Quote 0
            • Ryszard AdamusR
              Ryszard Adamus @PeterJones
              last edited by

              @PeterJones The regexp solution on that thread was for specific case, not universal. I also use regexp to mark the parts i need to check easily but can’t adapt that solution directly to my case. The python is even worse for me.

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

                Hello, @ryszard-adamus and All,

                In order to only get the marked ranges, with the red highlighting, you could either :

                • Use the Python @scott-sumner’s script    https://community.notepad-plus-plus.org/topic/12710/marked-text-manipulation/28

                OR

                • Use the following regex S/R :

                  • SEARCH (?s-i).*?(Your regex)|(?s).*\z ( or (?si).*?(Your regex)|(?s).*\z for insensitive to case search )

                  • REPLACE ?1\1\r\n

                This post is an update of this old post    https://community.notepad-plus-plus.org/topic/12710/marked-text-manipulation/8


                IMPORTANT :

                • Replace the expression Your regex by the string, the expression or the regex expression that you would have used, normally, in the Mark dialog

                • If you regex contains the dot symbol and tries to match text, in a single line, only, you MUST add the negative modifier (?-s), BEFORE your regex, in order to stop the action of the (?s) modifier, located at beginning of the overall regex !


                NOTES :

                • The first part (?s-i).*? matches the shortest range of characters, even null or on multi-lines, till the text that YOUR regex matches

                • The second part (Your regex), enclosed in round brackets, is the range of text, matched by YOUR regex, with the exact case, which is stored as group 1

                • The third and final part |(?s).*\z is a second alternative, which matches all the remaining text, even null, till the very end of the current file, when the first alternative cannot be matched, anymore !

                • In replacement, if group 1 exists ( first alternative ) this group is re-written, followed by a line break ( \r\n )

                • If group 1 does not exist ( case of the second alternative ), nothing occurs. So, as expected, the remaining text is, then, deleted


                EXAMPLE :

                • In the license.txt file, let suppose that you would like to extract all the longest single-line strings, matched by the regex (a.*j), in an insensitive way (?i)

                • Open the license.txt file

                • Iniitially, you would have marked these ranges of text with the regex, in the Mark dialog :

                  • SEARCH (?i-s)a.*j
                • Go back to the very beginning of your current file ( Ctrl + Home )

                • Open the Replace dialog ( Ctrl + H )

                  • SEARCH (?si)^.*?(?-s)(a.*j)|(?s).*\z

                  • REPLACE ?1\1\r\n

                • Select the Regular expression search mode

                • Click on the Replace All button

                Et voilà !


                Note that the @Scott-Sumner’s script and this regex S/R does give exactly the same results ;-))

                If you prefer, just tell me about the expression / regex, that you currently use to get your marked ranges and I’ll give your the exact syntax to build, from the generic regex S/R, above

                Best Regards,

                guy038

                P.S. :

                You must be aware about 3 points :

                • The regex S/R solution, above, is a destructive solution, in the sense that the original contents are lost ! Hence the need to copy the input text to a new tab, first !

                • If your regex, already, contains one or several capturing groups, you MUST increase by ONE the number of each capturing group, used in your OWN search regex, as, in my global regex, I use round brackets to define the first group 1 !!

                For instance, let’s suppose that you’re searching all the consecutive duplicate lines, in a sorted file, in order to extract them, leading to the common searched regex (?-s)^(.+\R)\1+. Once, inserted in the overall regex, the correct syntax is, therefore :

                (?s)^.*?((?-s)^(.+\R)\2+)|(?s).*\z ( and NOT (?s)^.\*?((?-s)^(.+\R)\1+)|(?s).\*\z ! )

                • If your regex matches complete lines, with their EOL characters, you’ll probably change the global replacement to the regex ?1\1 ( instead of ?1\1\r\n ), unless you prefer to space any matched expression by a blank line separator !
                1 Reply Last reply Reply Quote 1
                • Alan KilbornA
                  Alan Kilborn
                  last edited by

                  @Ryszard-Adamus said in Need a copy marked lines feature:

                  The regexp solution on that thread was for specific case, not universal.

                  @guy038 gives a “universal” solution above.

                  The python is even worse for me.

                  Because you don’t want to try it?

                  The Pythonscript may have an advantage in that if you want to redmark a bunch of different regular expression hits, you can do so, and then when you’re all done, you can run the script and copy ALL of the hits that it took you several marking operations to do.

                  1 Reply Last reply Reply Quote 1
                  • PeterJonesP
                    PeterJones @Ryszard Adamus
                    last edited by

                    @Ryszard-Adamus said in Need a copy marked lines feature:

                    The regexp solution on that thread was for specific case, not universal

                    You read the wrong post then, or misunderstood the post you did read. I didn’t say anything about regex, and neither did the post I linked.

                    The post I was referring to is https://community.notepad-plus-plus.org/post/24733, which as Guy said could also be linked as https://community.notepad-plus-plus.org/topic/12710/marked-text-manipulation/18, by @Scott-Sumner on
                    May 31, 2017 at 12:19PM (might be timzone adjusted for you), with the text “So here is RedmarkedTextToClipboard2.py:”, followed by Python code.

                    The script assumes you have already marked your text from the Find > Mark dialog; the script searches the document for all the marked text, and adds all that text into the copy buffer. That’s exactly the procedure you described.

                    I was about to explain the steps involved in installing PythonScript and running the described script, but …

                    How Rude

                    … but now I see you’re running off in a huff, deleting your post. That is poor behavior in any forum anywhere.

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

                      @PeterJones said in Need a copy marked lines feature:

                      I see you’re running off in a huff, deleting your post. That is poor behavior in any forum anywhere.

                      @guy038 , as an admin, should restore the original post for any future readers/searchers?

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

                        Hello, @Alan-kilborn, @peterjones and All,

                        I would say that, when running successive mark processes, each method has advantages and drawbacks !

                        • The script solution keep the natural order of lines of the file and will be more compact, as a single line is created, in case of overlapping matches of the different regexes !

                        • The regex solution does not keep the order of the lines, but better distinguishes the matches of each regex, in case of overlapping matches, as a line is created for each match

                        Best Regards,

                        guy038

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

                          Hello, @Alan-kilborn, @peterjones and All,

                          I don"t know if it would be fair to go against the will of the OP, but but I’ve come up with a compromise :

                          I changed the intial title Need a copy marked lines feature

                          with this new title Need a copy of the red marked regions, after a "Mark All" operation

                          BR

                          guy038

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

                            @guy038

                            in case of overlapping matches

                            Well, I meant non-overlapping matches of course. Often while marking data it is simpler to come up with 3 or 4 successive marking operations on different data in order to capture everything you want; coming up with one regex, while perhaps an interesting exercise, would likely be distracting from your at-hand task.

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