Repeating search with F3 for original string before using Replace

Repeating search with F3 for original string before using Replace

4
NewbieNewbie
4

    Mar 30, 2011#1

    I've just upgraded from an older version of UE to version 17 and am finding the search behaviour quite different. I would like to find out what settings (if any) will make 17 behave in the same way as the older versions.

    I open a file and "Find" a string, say abc. I then do a Find and Replace, say replace def with ghi. In the older versions when I then press F3 they would search for abc, i.e. the original search string. The newer version searches for def, i.e. the last string searched for to do the find and replace.

    How do I set v17 to behave like the older versions (v12.20b+1)?

    Bob.

    6,675585
    Grand MasterGrand Master
    6,675585

      Apr 02, 2011#2

      I tested this with UE v12.20b+1. This versions works as all other versions of UltraEdit. But I think I found out why you think that Find Next/Prev worked in UE v12.20b+1 with last used search string of find dialog and ignores last searched string used in the replace. I explain it step by step.
      1. It is important to enable the configuration setting Find Next/Prev finds selected text (not last searched for text) at Advanced - Configuration - Search - Miscellaneous.
      2. Next open changes.txt of UE v17.00 in UltraEdit program directory.
      3. Press Ctrl+F to open the Find dialog and enter the word line.
      4. Make sure no other search option except advanced option Close this dialog after find is checked. Especially the option Regular Expressions should not be enabled because that option turns off the Find Next/Prev finds selected text feature.
      5. Execute the find now with button Next. First line is found and selected.
      6. Press F3 to execute a Find Next. Second line is found and selected.
      7. Press now Ctrl+R to open the replace dialog. The selected line is preset in the Find What field. But replace this word by improved and enter as replace string whatever you want.
      8. No other option should be checked, except Close this dialog after replace all. Press button Replace All. All occurrences of improved are now replaced by the entered replace string.
      9. As you see the word line is still selected although the replace all was executed. Pressing now F3 therefore results in searching for line. But that happens because line is selected and the configuration setting Find Next/Prev finds selected text is enabled and not because of last used search string in find dialog.

      4
      NewbieNewbie
      4

        Apr 02, 2011#3

        Mofi,

        Thanks very much for taking the time to look into this and providing guidance.

        I've figured out what the difference is between the ways you and I are doing things.

        If I follow your example exactly I get the same result you do, i.e. F3 finds line at the end of the process.

        The difference is in the way I usually get improved into the Find What field in Replace. If I type it in I get your result. However, if I get it in that box by selecting it in the body of the file, it works very differently. Often the strings I am wanting to Find and Replace are quite long and complex and I really don't want to have to type them in the Find What box. In the older versions I just selected the string I wanted to replace and then opened the Replace window, did the replacement and the next F3 reverted to the original abc equivalent.

        I am doing things like Find .sms, Replace ..\\..\\MT_Common.sound\\MT_SW_2cyl_generic\\MT_SW_2c-100a-8F-eng01 with ../../../../commonsounds/2cyl_generic/2c-100a-8F-eng01. Find next .sms and so on.

        It looks like under the new version what I'll have to do is turn on the Find dialogue defaults to word under cursor, do my first Replace, select .sms from the body of the text and press F3.

        Regards,

        Bob.

        6,675585
        Grand MasterGrand Master
        6,675585

          Apr 03, 2011#4

          I'm still interested in if there is a difference in search behavior of UE v12.20b+1 in comparison to UE v17.00 and I still can't find one. So you are using normally following steps:
          1. Ctrl+F is pressed to open the Find dialog and a word like line is entered, if not already selected in the active document window before opening the dialog and therefore automatically set as search string.
          2. No other search option except advanced option Close this dialog after find is checked. The find is executed now with button Next. First line is found and selected.
          3. F3 is pressed to execute a Find Next. Second line is found and selected.
          4. Now a different string is selected in the active document window before pressing Ctrl+R to open the replace dialog. The selected string is preset in the Find What field. Therefore just the replace string must be entered.
          5. No other option is checked, except Close this dialog after replace all. Button Replace All is pressed and all occurrences of the selected and searched string are now replaced by the entered replace string. That includes also the string selected before opening the replace dialog. Instead of the string selected before pressing Ctrl+R, the replace string is selected now in active document window.
          6. Pressing now F3 results in searching for the string used in the previous replace as search string which of course is normally not found anymore, if the configuration setting Find Next/Prev finds selected text is not enabled. If configuration setting Find Next/Prev finds selected text is enabled, pressing F3 results in searching for the selected string which is the last used replace string. If manually the last searched string of last find command is reselected again before pressing F3, pressing F3 now results in searching for this selected string.
          That behavior is the same in v12.20b+1 and in v17.00. To search again for the string used last time with find command, it is necessary to open the find dialog with Ctrl+F, press key DOWN ARROW to choose the last but one search string from search string history, and execute the find with pressing key RETURN. I can't see a difference here between UE v12.20b+1 and UE v17.00.0.1025 (build 1028 not yet installed).

          The configuration setting Find dialog defaults to word under cursor is only important if nothing is selected in active document window currently and Ctrl+F or Ctrl+R is pressed to open the Find/Replace dialog. With this configuration setting enabled, the word under the cursor is preset in the Find What field even when not seletected. If a string is selected before pressing Ctrl+F or Ctrl+R, this configuration setting has no effect because a selected string is used always as search string.

          4
          NewbieNewbie
          4

            Apr 04, 2011#5

            I was beginning to think I was perhaps imagining things 8) so I set up a little test to see if I could prove I was right.

            I first made sure that v17.0 and v12.20b+1 had the same settings.

            So in Advanced\Configuration\Search\Miscelaneous the only ticked boxes were "Continue Find at End of File", "Find Next/Prev finds selected text (not last searched for text)", "Set focus...." and in v17 only "Fill search in columns....".

            In Find, "Close this dialog after find" in v17.

            In Replace in Files, "List Changed files" and "Search subdirectories".

            I created two files called test1.txt and test2.txt. Both of them contain ten lines:
            abc
            def
            abc
            def
            abc
            def
            abc
            def
            abc
            def

            I opened test1.txt and performed the following steps with the following results:
            1. cntrl-F, type abc in Find What box, Next -----> abc in line 1.
            2. F3 -----> abc in line 3.
            3. F3 -----> abc in line 5.
            4. Select def in line 6.
            5. Replace in Files, def is already in Find What, type ghi in Replace With, Replace All.
            6. Click anywhere in file so nothing is selected, F3.

            After the last step, v17.0 opens a window saying "Search string 'def' not found" and v12.20b+1 goes to abc in line 7.

            QED.

            6,675585
            Grand MasterGrand Master
            6,675585

              Apr 04, 2011#6

              Aha, you use the Replace in Files command and not the Replace command which makes a difference. Yes, now I can see also the different behavior between UE v12.20b+1 and UE v17.00. But the reason for this different behavior is not by design, it is caused by a bug in UE v12.20b+1. The 4 commands Find, Replace, Find in Files and Replace in Files have the same [Find History] and the 2 commands Replace and Replace in Files have additionally the same [Replace History] history.

              With all histories cleared, searching for abc results in

              [Find History]
              0="abc"
              [Replace History]


              Running now a Replace in Files changes the history lists to

              [Find History]
              0="def"
              1="abc"
              [Replace History]
              0="ghi"


              Therefore executing now Find Next command should result in searching for def. But in UE v12.20b+1 that does not happen. The reason is that there is additionally

              [Find/Replace]
              FindString="abc"
              ReplaceString=""


              and although the history lists are common for all 4 commands, in UE v12.20b+1 the last used FindString and ReplaceString entries are not updated by a Find/Replace in Files. That results in the behavior you would like although it is wrong. Closing UE v12.20b+1 now and restarting UE with opening the text file again results in showing def in the find list box in the toolbar, but command Find Next searches nevertheless for abc. Also opening the Find dialog with Ctrl+F and nothing selected in active document window (and caret not placed near a word), results in UE v12.20b+1 in displaying abc (from FindString=) as preset search string while opening Find in Files results in displaying def as preset search string (from 0= in [Find History]).

              That not really correct behavior is fixed in UE v17.00. Now after running a Find/Replace in Files command the last used search/replace string is always really used also for next Find/Replace command according to the histories. In other words FindString= and ReplaceString= are now also updated by a Find/Replace in Files command.

              4
              NewbieNewbie
              4

                Apr 04, 2011#7

                Yes, sorry about that. It was only when I was working through my example that I realised it only worked differently in Find In Files.

                It's unfortunate that the behaviour I prefer is a "bug" and has been "fixed". It looks like my workaround will have to be to turn on the "Find Next/Prev finds selected text (not last searched for text)" and every time select abc (in my example) before doing the next Find.