Find in selected text instead of searching for selected text

Find in selected text instead of searching for selected text

12
Basic UserBasic User
12

    Feb 19, 2010#1

    I've just installed UE 15.20 on XP.

    I've gone to Customization -> Search -> Miscellaneous and cleared the fields to deselect "Find dialog defaults to word under cursor" and deselect "Find Next/Prev finds selected text (not last searched for text)". I have then restarted UE.

    But when I do a search it's still insisting on overwriting my existing search text with whatever text is selected (that I want to search within). Any ideas how to fix that? Thanks!

    6,675585
    Grand MasterGrand Master
    6,675585

      Feb 19, 2010#2

      It is normal behavior that everything currently selected is automatically entered in the Find What edit field after pressing Ctrl+F. There is no configuration setting to change this behavior. If you don't want to search for the selected text, but search inside the current selection for the last searched string simply press key DOWN ARROW after pressing Ctrl+F to replace the selected text in the Find What field with the last searched string from the find history. When you want to search for a new string in the current selection, just type the new string after pressing Ctrl+F. Next you have to press Alt+L to select option Selected Text and when everything else is correct you can run the search with pressing key RETURN.
      Best regards from an UC/UE/UES for Windows user from Austria

      12
      Basic UserBasic User
      12

        Feb 19, 2010#3

        Then what do those two config settings do?

        What on earth would be the point, when searching in a selection, of choosing the entire selection as the search string?

        6,675585
        Grand MasterGrand Master
        6,675585

          Feb 19, 2010#4

          Help of UE wrote:Find dialog defaults to word under cursor

          If this option is selected the editor automatically initializes the find/replace dialogs with the word under the cursor position. If not set, it uses selected text if present or the last find string.


          Find Next/Prev finds selected text (not last searched for text)

          If this option is selected the editor will find the selected text when a FIND NEXT/PREVIOUS command is performed instead of the previous search string UNLESS the Regular Expressions option is selected.
          I explain the settings on an example.

          This is just a |sample text for demonstrating the behavior of the 2 search settings.

          In the line above | marks the current cursor position and nothing is selected. With Find dialog defaults to word under cursor enabled pressing Ctrl+F opens the Find dialog and the word sample is automatically entered in the Find What field although not selected. So with this option enabled it is not necessary to select first a word you want to search for. It is enough that the cursor is at beginning, inside or end of the word to have it automatically as search string preselected when opening the Find or Replace dialog. If this option is not enabled, the word to search for must be selected or the previous search string is preselected in the find/replace dialogs.

          The setting Find Next/Prev finds selected text (not last searched for text) is only for the commands Find Next with default hotkey F3 and Find Prev with default hotkey Ctrl+F3. With this option enabled you can select something and press F3 or Ctrl+F3 to search for the selected string without opening the Find dialog, unless the regular expression find option is enabled, instead of searching again down or up what you last searched for.

          UltraEdit cannot automatically determine on opening Find/Replace dialog and a selection exists, if a search for the selected text should be done, which is definitely the most wanted behavior, or a search for something other in the selected text. It is definitely better to use by default the selection as search string because the opposite behavior with just selecting option Selected Text and use last search string would force every user who wants to search for the selection to copy it to clipboard and paste it into the edit field and change the option to Current File. Simply pressing key DOWN ARROW, when search in selected text instead of search for selected text is required, is surely the better default behavior.
          Best regards from an UC/UE/UES for Windows user from Austria

          12
          Basic UserBasic User
          12

            Feb 19, 2010#5

            Okay. I can understand many people will search what's under the cursor. For me, that's never something I've needed, I'm almost always looking for something that was typed in last time or will be typed in this time and would like it to default to "same as previous".

            If I wanted to reassign Find... and its shortcut CTRL-F to a macro or script that would pop up the Find dialog and auto-enter the down key (or programatically reinsert the same value as last time), can you show me what that would look like? I'd prefer a script because it can potentially be extended to amend other fields in the default find dialog if needed.

            This would probably be the best solution for me :)

            6,675585
            Grand MasterGrand Master
            6,675585

              Feb 19, 2010#6

              Well, when setting Always set 'Find/Replace Where' to 'Current File' in Find/Replace dialog at Configuration - Search - Auto Reset Settings is not enabled, the option Selected Text is remembered and you perhaps can use the Search box in the toolbar to search for last string in selected text or enter a new string. But when nothing is selected nothing will be found.

              It is not possible from within a macro or script to open the find or replace dialog and control their parameters. You can write a script which asks you for the search string and then runs a find with the options you specified in the script. But it is not possible to change anything displayed in the dialogs by running a script with the find command and setting the find options and scripts also don't have access to the search/replace histories. Scripts run always in their own environments not modifying the users' environment. That is very important because otherwise scripts and macros would always modify the users' settings and histories which really nobody who uses often scripts and macros wants.

              Here is a little script to find the first occurrence of the entered string in selected text:

              Code: Select all

              if (UltraEdit.activeDocument.isSel()) {
                 UltraEdit.activeDocument.findReplace.mode=1;
                 UltraEdit.activeDocument.findReplace.matchCase=false;
                 UltraEdit.activeDocument.findReplace.matchWord=false;
                 UltraEdit.activeDocument.findReplace.regExp=false;
                 UltraEdit.activeDocument.findReplace.searchAscii=false;
                 UltraEdit.activeDocument.findReplace.searchDown=true;
                 UltraEdit.activeDocument.findReplace.searchInColumn=false;
                 var sSearchString = UltraEdit.getString("Find What:",1);
                 UltraEdit.activeDocument.findReplace.find(sSearchString);
              }
              But this solution is surely not really good for you.

              You can request by email to IDM support an enhancement like an additional configuration setting which determines the behavior when Find/Replace dialog is opened and somthing is currently selected. For example the configuration setting could be:

              Always set 'Find/Replace Where' to 'Selected Text' in Find/Replace dialog with selection
              If this option is selected, the 'Find/Replace Where' option in the Find/Replace dialogs will always be set to 'Selected Text' and the previous find string is preset when the dialogs are invoked and a text is selected. If this option is not selected, the selected text is used as find string and 'Find/Replace Where' option depends on the previously used value and the auto reset settings. This option has no affect when nothing is selected on invoking the dialogs.

              However, I for myself use option Selected Text very, very rarely and so I'm not interested in an enhancement. So take my suggestion just as advice how you can formulate your enhancement request to IDM.
              Best regards from an UC/UE/UES for Windows user from Austria