|Home » Products » UltraEdit/UEStudio » Menu Commands (UE) » Search|
Replace in Files command
Article Number: 1330 | Last Updated: Fri, Oct 21, 2011 3:14 PM
This command displays a dialog box for searching for a text string in files on a disk and replacing it with another text string.
The string to search for is specified in the Find What  field and the replace string to used is defined in the Replace With  field. Single or multi-line strings up to 20,000 bytes may be used in both fields. The files to search are specified in the In Files/Types and Directory fields. The Directory  field specifies the directory to search and the In Files/Types  field specifies the filename or types. The filename may contain wildcards (an asterisk) and may also contain multiple file types separated by semicolons, i.e.:
The Directory  field may contain multiple search paths separated by semicolons, i.e.:
If the button is pressed the find history is displayed.
If the button is pressed a submenu with the following options are presented:
If the button is pressed a list of regular expression options appropriate to the selected Regular Expression Engine is displayed. This button is subdued unless the Regular Expressions checkbox is selected.
Replace Where 
Users may specify if changes should be made to Files Listed, Favorite Files, Project Files, or Solution Files. If Files Listed is selected then the File Types and specified Directory will be used to determine the files to be modified by the Replace operation. If Project Files or Solution Files is selected then the Replace would affect all files included in the active project/solution.
When the find/replace is executed, each file where the find string is found is modified and each occurrence of the string is replaced with the replace string. If the file is read only, the file is not modified and a message box is posted. At the end of the operation, a dialog box is displayed indication how many times the replace occurred and how many files were modified.
The following search options  exist:
Match Whole Word Only
By default, the search will not re restricted to matching whole words only. This option allows the search to be restricted to whole words only. This is useful for searching for ' a ', or 'A' without finding all words including 'a'. If a search has already occurred in a document, the default selection will match the previous search.
By default, the search will not be case sensitive. The option to make the search case sensitive is given. This option also affects regular expressions. If this is not checked, [A-Za-z] and [A-Z] are equal to [a-z].
If this option is selected the search will be executed using the regular expression type selected under the Advanced section.
Advanced Options 
Pressing the Advanced button extends the Find in Files dialog to display additional search options.
Perl Compatible Regular Expressions
If this option is selected the editor will use Perl style regular expressions based on the Boost C++ Libraries.
UltraEdit Style Regular Expressions
If this option is selected the editor will use UltraEdit style regular expressions.
UNIX Style Regular Expressions
If this option is selected the editor will use UNIX style regular expressions.
For information regarding creation of regular expressions see Regular Expressions or Perl Regular Expressions help.
The option to preserve cases causes UltraEdit to match the case of the replace string with the case of the found string. The rules for this are as follows:
1) If the word found is all lowercase the replacement word will be all lower case
2) If the word found is all UPPERCASE the replacement word will be all UPPERCASE
3) If the word found is MixedCase the replacement word will MATCH the casing of the replacement word.
Example: (Find "The", replace with "Then")
"the" will be replaced with "then"
"THE" will be replaced with "THEN"
"The" will be replaced with "Then"
The mixed case example requires the replacement word specified to have the mixed case in the replacement string that is required for the result so that a word that may have multiple mixed case characters may be correctly replaced, not just capitalization.
Replace " NextCharacter" with " PreviousCharacter" would replace:
" nextcharacter" with " previouscharacter"
" NEXTCHARACTER" with " PREVIOUSCHARACTER"
" NextCharacter" with " PreviousCharacter"
By default, only files specified in the specified directory are searched. This instructs the search to search all subdirectories of the specified directory. If the Ignore hidden subdirectories option is selected, then subdirectories which are hidden (as defined in Microsoft Explorer) will not be included in the search.
If desired, the user may exclude subdirectories by specifying them in the Subdirectories to ignore in search field. Multiple names should be separated by a semicolon. Users may also specify file names or extensions which should be ignored in the search in the File names/extensions to ignore in search field. For example: "*.cpp;index.*;" would instruct the search not to match files with a "*.cpp" extension or files that are named "index" (regardless of extension).
List Changed Files
This instructs the editor to list all the files that were modified in the Output Window. If set, each file change will be listed in the Output Window followed by the number of occurrences found and changed.
Interactive Replace in Files
If the Start button is pressed rather than the Replace All button, an interactive dialog will be shown when the Replace in Files operation finds a match for the search string. If the Replace All button is pressed, the Replace in Files operation will proceed without any prompts for user interaction after the standard warning prompt is displayed.
The interactive dialog will offer the user five options:
By default this option is disabled. When the checkbox is selected, the dropdown may be used to specify the encoding to be used when searching for the specified string.
Open matching files
If this option is selected, any files matching the specified parameters will be opened when the search completes.
There are no attachments for this article.
Find Prev command
Viewed 3870 times since Thu, Oct 13, 2011
Viewed 4346 times since Thu, Oct 13, 2011
Toggle Bookmark command
Viewed 5995 times since Thu, Oct 13, 2011
Select to matching brace command
Viewed 6132 times since Thu, Oct 13, 2011
Viewed 4776 times since Thu, Oct 13, 2011
Viewed 12551 times since Thu, Oct 13, 2011
Find Next command
Viewed 4372 times since Thu, Oct 13, 2011
Regular Expressions (Perl Style)
Viewed 9527 times since Thu, Oct 20, 2011
Viewed 4858 times since Thu, Oct 13, 2011
Word Count command
Viewed 12349 times since Thu, Oct 13, 2011