UltraEdit PowerTips

Using find, replace, find in files, and replace in files-Linux

UltraEdit gives you the ability to perform a find or replace through one or more files. There are multiple configuration options which allow you to target specific file types, project files, directories of files, and more. Using the available tools, you can customize your find or find/replace to quickly make changes to text or code in a directory of files, or to locate a unique string within a single file buried in hundreds of other files, and even find files that do not contain a specific string.

Using Find, Replace, Find In Files, and Replace in Files

All of the search features covered here may be accessed under the “Search” menu.


You can search your open file by selecting the “Find” option from the “Search” menu. Once you select this option, a dialog box will prompt you for your search terms. Here you can also specify other “find” options. To quickly search, type in what you are looking for and press “Find Next.”

The first found string will be highlighted in the file while the Find dialog stays open. You can then step through all occurrences of the string in the file by pressing F3, which will take you to the next instance found. Press CTRL+F3 to return to the previous instance.

You are given several options in the find dialog that you can use to customize your search.

Match Whole Word

UltraEdit will not restrict a search to matching whole words only. This option restricts the search to whole words only. Whole words are words separated, on both sides, by a space.

For example, select this option if you want to search for ‘a’, or ‘A’ without finding all words that include ‘a’.

Match Case

By default your search will not be case sensitive. Selecting “Match Case” will result in UltraEdit searching for only case-sensitive matches.

Regular Expressions

A regular expression search allows you to search for strings that are different but are composed of a similar pattern. For instance, in the below example, our search string of “<.*>” is a special syntax that will match ANY string composed that begins with “<” and ends with “>”.

This search is done using Perl-style regular expressions, which may be configured in Advanced : Configuration : Search : Regular Expression Engine, or by clicking on the Advanced button (on the find dialog) and selecting the particular engine.

The “.” in our search string tells UltraEdit to find any character that is not a new line, and the “*” character qualifies that by telling UltraEdit to search for this and match it 0 or more times. Therefore, all of the following strings would be matched:

  • <>
  • <a href=”#top>
  • <img src=”images/powertips/uex/search4.png” alt=”UltraEdit Searches” border=”0″>

However, the following string would not be matched since it contains a line break (new line). While the “.” character will match any character, it will not match a line break.

  • <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”


Click here to find more information on Perl-style regular expressions. Additional information about regular expression syntax is available in the Help file under the “Regular Expression Engine” section.

Find Where

Current File

If you select this option, UltraEdit/UEStudio will perform the search in the current file.

Selected Text

If you select this option, UltraEdit/UEStudio will ONLY search in the currently selected text.

Find Next through all opened files

If you select this option, repeating the Find Next command (F3) will continue to cycle through all open files after finishing the search through the active file.

Beyond the items mentioned thus far, there are additional configuration items available. To view the additional options, click on the right-arrow button next to the Options label.

Highlight All Items Found

This option will result in all items matching the search string to be highlighted, or shown as selected text, when the Find Next button is pressed.

List Lines Containing String

Selecting this option will cause UltraEdit to search for all occurrences of the string in the active document and list them in a dialog box. When the list lines containing string dialog opens, you can double-click on a result line and UltraEdit will position to that line in the file. You may also select the result line and click on Goto.

Search in Column

Selecting this option will allow you to narrow your search result to a beginning (From) column and end (To) column.

Count All (Count Occurrences)

This button will count the number of occurrences of your search string in the active file.

Recent Search History

If you would like to view the recent search history, you can select the entire text (Select All – CTRL + A) of the Find dialog and press the up/down arrow to cycle through the history. Additionally, you can click the clock icon to select an item from your search history.

Search Favorites

The star icon on the Find/Replace dialog allows you to save a list of your favorite searches. This can be especially useful for complex regular expression patterns.

To use an item stored in the favorites list, simply click the Star icon and navigate to Favorites, and select the item.


The “Replace” option under the “Search” menu will invoke the Replace dialog. This allows you to search for a phrase or string and then replace it with a different phrase or string.

There are several options for configuring your search in the Replace dialog. For our purposes, we will do a simple search and replace, replacing all occurrences of “1,000,000” with “2,000,000” as shown below.
You can select “Replace All,” and all instances of your string will be replaced immediately.

As you can see below, our text in the document has been replaced with our replace string.

Further Replace Options

There are some additional options and configurations unique to the Replace dialog when you first invoke a replace. The options for “Match Whole Word Only”, “Match Case”, “Regular Expressions”, and “Replace Where” work the same as in the Find dialog (see above).

To see the additional (Advanced) options, click on the Advanced button.

Preserve Case

The option to preserve cases causes will 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.


For example, if this option is selected and you search for “The” and replace it with “Then,” the following replaces would occur:

  • “the” will be replaced with “then”
  • “THE” will be replaced with “THEN”
  • “The” will be replaced with “Then”


Replace All is from Top of File

If this option is selected the specified search will be executed from the top of the active file rather than the current cursor position. This setting is important because a “Replace All” could (potentially) skip a find/replace that is above the cursor position.

Close this dialog after replace

If this option is selected the dialog will close after the command has been executed.

Find in Files

The “Find in Files/Replace in Files” options are accessible under the “Search” menu. These powerful search options allow you to search for strings or text within multiple files contained in a directory.

Selecting the Find in Files option will bring up a Find in Files dialog box. This box allows you to configure the parameters of the search.

 For our example, we would like to find the string “2,000,000” in all of our HTML files in our “htmlBackup” directory.

In Files/Types

Setting the “In Files/Types” to *.html tells UltraEdit to search ONLY HTML files. If you would like to search in multiple file types, you may list additional file types separated by semicolons (ie. *.html; *.txt; *.php).

In Directory

You can click the “Browse” button to browse through your computer for the directory you’d like to search. If you wish to search sub directories, below the primary directory, make sure to select the “Include subdirectories” option.

Once we press the find button, our search begins. On larger directories with many files, the search may take several minutes. By default, the results of our search will be written to an output window.

Replace In Files

The “Replace in Files” option, located under “Find in Files” in the “Search” menu, is probably one of the most powerful Find/Replace functions in UltraEdit. This allows you to edit massive amounts of files with just one click. Like the other search/replace functions, selecting this option will invoke a “Replace in Files” dialog where you can specify the parameters of your search and replace.

It is important for you to understand the replace in files command before you issue it because all changes are permanent and cannot be “undone”. We therefore suggest doing a test before executing the command on the actual data, or making a backup of the actual data before running the replace in files.

In our example below, we have specified that all HTML files in our “htmlBackup” directory will be searched for “1,000,000”, and all matches will be replaced with “2,000,000”. We have selected the option to “List Changed Files,” because we would like to know exactly where UltraEdit found a match and replaced it.

Once you’ve set these parameters to meet your specifications, you can press the “Replace All” button to begin the Replace in Files. As with the “Find in Files” function, depending on the amount of data, a “Replace in Files” over many files can take several minutes to complete.

When the replace is complete the results summary is written to the output box. The summary tells you exactly where the replace occurred and how many times it occurred in each file.

The additional options in the “Replace in Files” dialog, that were mentioned previously for the Find in Files description, perform the same function (as described above) in the Replace in Files.