Community
    • Login

    Shift+F3 no more works

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    15 Posts 7 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.
    • mkupperM
      mkupper @reinhardhofmann
      last edited by

      @reinhardhofmann Your observed behavior is “normal behavior” for Notepad++. There is a “gotcha” with it.

      If you bring up the finder window (Ctrl-F) the Search Mode choices in the lower-left corner are Normal, Extended, and Regular expression. Shift F3 works if you are in Normal or Extended mode. Shift-F3 does not work if you are in Regular expression mode.

      @guy038 gave you a “back door” thing that enables Shift-F3 when in Regular expression mode. It’s in the Notepad++ manual and so it’s not like it’s a super-secret thing… :-)

      @Alan-Kilborn warns that there may be unusual behavior when doing a backwards regular expression search using shift-F3. The manual warns you about “sometimes surprising results” but other than that, it’s best to dial up your favorite mysterious music when attempting to discover edge conditions of what happens if you perform regular expressions, backwards.

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

        @mkupper said in Shift+F3 no more works:

        it’s best to dial up your favorite mysterious music when attempting to discover edge conditions of what happens if you perform regular expressions, backwards.

        @PeterJones Maybe the user manual should provide an example?

        PeterJonesP 1 Reply Last reply Reply Quote 2
        • PeterJonesP
          PeterJones @Alan Kilborn
          last edited by

          @Alan-Kilborn said in Shift+F3 no more works:

          Maybe the user manual should provide an example?

          If someone were to create an issue in the UM repo, and provide an example regex that will not work as expected in backwards mode, I could add it into the manual. (But I don’t know how to craft a simple regex that would have an obvious meaning when searching forward, but mess up when searching backward, so I cannot come up with an example myself.)

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

            @PeterJones

            It seems like there should be one when that “power user” mode thing was added to Notepad++. I’ll see if I can find it.

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

              Hi, @reinhardhofmann, @alan-kilborn, @mkupper and All,

              Hi, All, do you know that, even with the regexBackward4PowerUser enabled, there are still some cases where the backward regex search do not work ?

              For example, in a new tab, copy this text :

              This is à test
              This is à second test
              This is à third test
              This is à final test
              

              Note that, in each line, I replaced the indefinite English article a with the French accentuated letter à !

              • Move to the beginning of this file

              • Select the à letter, in line 1

              • Open the search dialog ( Ctrl + F )

              • Tick the Wrap around box option

              • Select the Regular expression search mode

              • Hit on the Find Next button

              => The à char, in line 2, should be selected

              • Close the Find dilaog ( Esc )

              • Hit the F3 key

              => Again, the à char, in line 3, should be selected

              • Now, use the Shift+ F3 shortcut => Nothing happened ???

              ( Of course, I suppose that you do have the string regexBackward4PowerUser="yes", in your active config.xml file ! )


              This happens ONLY IF :

              • Your search mode is Regular expression

              • The searched character is over \x{007F}

              • The current encoding file is an Unicode one : UTF-8, UTF-8-BOM, UTF-16 BE BOM or UTF-16 lE BOM


              Luckily, I’ve found a way around this limitation. The rule is :

              When a backward regex do not work as expected, simply add the regex string (?=(?s).) at the end of the present regex !

              Thus, if we, now, search for the regex à(?=(?s).), you should be able to search backwards or forwards, at any time !

              Best Regards,

              guy038

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

                Hello, @peterjones, and All,

                Regarding examples to include in the Official documentation, here are two examples which :

                • Do not work at all, in backward direction, if the regexBackward4PowerUser is not set

                • Else, allows the regex backward search but gives right results in the first example only


                Let’s consider the following text, where I included, this time, the classical English a article :

                This is a test
                This is a second test
                This is a third test
                This is a final test
                
                • If the regexBackward4PowerUser option is enabled ( "yes" ) :

                  • The regex (?-s)i.*te does find the greatest range of characters, between a i letter and the te string in BOTH forward AND backward search

                  • The regex (?s)i.+ does find the greatest range of chars, beginning with an i letter, in forward search BUT finds multiple wrong occurrences when used in backward direction !

                • If the regexBackward4PowerUser option is disabled ( "no" ) :

                  • The two regexes works as expected in forward direction and CANNOT be used in backward direction

                BR

                guy038

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

                  @guy038

                  even with the regexBackward4PowerUser enabled, there are still some cases where the backward regex search do not work ?

                  YES! No one ever said all regexes work fine moving backward in this mode. If they did, there’d be no need for the mode to exist at all!

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

                    @guy038 said in Shift+F3 no more works:

                    The regex (?s)i.+ does find the greatest range of chars, beginning with an i letter, in forward search BUT finds multiple wrong occurrences when used in backward direction !

                    What about (?s)i.+(?=.) for this case?
                    (I’m away from my Notepad++ PC right now so I can’t try it)

                    1 Reply Last reply Reply Quote 0
                    • Mark OlsonM
                      Mark Olson
                      last edited by

                      Nobody has talked about trying to actually solve the issues with backward regex searching, but it seems to me like a potential solution might be along these lines:

                      when someone regex-searches backwards:
                          if need-to-re-search-file:
                              regex-search the entire file starting from the beginning
                          find the last match before the current position
                      when someone edits a file or changes the regex to be searched:
                          set need-to-re-search-file = true
                      

                      Obviously I’m not saying this would be easy and I fully expect it would be very hard to implement, but what do people think about that idea?

                      CoisesC 1 Reply Last reply Reply Quote 1
                      • CoisesC
                        Coises @Mark Olson
                        last edited by

                        @Mark-Olson said in Shift+F3 no more works:

                        Nobody has talked about trying to actually solve the issues with backward regex searching

                        Perhaps I have missed it, but I have not yet seen the issues precisely defined. In particular, I haven’t seen it stated whether the problem is that:

                        1. the expected result of backward searching with a regular expression is not always well-defined.

                        2. the expected result is well-defined, but the implementation — due to Boost, Scintilla, Notepad++ or some combination thereof — is not always correct.

                        Is it known which applies, and under what specific conditions?

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

                          Hello, @reinhardhofmann, @mkupper, @alan-kilborn, @peterjones, @mark-olson, @coises and All,

                          Oh…, in my previous post, I did a mistake : I spoke about a second example (?s)i.+. But, I really did tests with the regex (?-s)i.+ !

                          When the backward regex search is allowed, EACH backward regex (?-s)i.+ finds a string, reduced by a single character

                          But, unfortunately, Alan, the regex (?-s)i.+(?=(?s).) do not give the expected results, allthough it reduces the number of steps before a CORRECT backward occurrence !


                          Thus, my general rule should be modified as :

                          When a backward regex do not work as expected, try adding the regex string (?=(?s).) at the end of the present regex. It may work correctly !

                          Best Regards,

                          guy038

                          1 Reply Last reply Reply Quote 0
                          • CoisesC
                            Coises @Coises
                            last edited by

                            I wrote in Shift+F3 no more works that the problem might be:

                            the expected result of backward searching with a regular expression is not always well-defined.

                            Example of how this could be ambiguous:

                            Given the text:
                            xabcdefy
                            and the regular expression:
                            (a..(d..)?|.e)

                            when matching normally there is one match — abcdef. When matching backward, is there one match — abcdef — or are there two matches — de and abc?

                            What about the regular expression:
                            (a..(d.)?|.f)
                            matching backward: abcde or ef and abc?

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