I have 2 files open. I want to select and copy text from the first file and then find that selected text in the second file. Can I get a macro to do that? In normal editor mode, after the 1st select/copy I have to move to the second file, select FIND, paste in the select buffer and then click NEXT. I'm struggling to get this done in a macro
- selecting the text in active file,
- opening regular find window resulting in using the selected text automatically as string to find,
- switch now to the other file while find window is still opened in foreground (or docked in case of using docked find window),
- run the find on new active file.
But you have asked for an UltraEdit macro solution and here it is using user clipboard 9 as buffer for selected text.
- Code: Select all
The help page of Find/Replace/Find in Files/Replace in Files can be opened by pressing key F1 on floating Find and Replace window being opened and having input focus. On help page for Find command is described ^c for referencing contents of active clipboard and ^s for referencing selected text in active file. See also Usage of ^c (clipboard content) and ^s (selected text) in search and replace.
Some additional notes regarding the macro:
The Find executed from within a macro is always from current caret position in active file to bottom of the file. The configuration setting Continue find at end of file being by default enabled is not active on running a find from within a macro or script to avoid an endless running macro/script.
If the macro property Continue if search string not found is not checked for this macro, the last three macro commands are not executed if the searched string could not be found in other file after displayed the message box that the searched string is not found. This results in user clipboard 9 still containing the copied string and being still the active clipboard instead of Windows clipboard. Ctrl+C and Ctrl+V in opened Find window as wells as copying/pasting to other applications works only with Windows clipboard. Therefore it is better to use as fourth macro line Clipboard 0 and remove ClearClipboard and Clipboard 0 from bottom of macro on having macro property Continue if search string not found not checked.
But with a checked macro property Continue if search string not found nothing is displayed if the string is not found from current caret position to end of file.
So it might be better to use an UltraEdit script for this task which can check for current position of caret in file to search and roll over to beginning if needed with restoring initial caret position in case of string not found anywhere in file and which can also show a message box if the string could not be found in entire file.