Edit online

Find/Replace in Multiple Files

The Find/Replace in Files feature enables you to define Search for or Search for and Replace operations across multiple files (for example, in DITA projects you can search in the scope of an entire DITA map). To open the Find/Replace in Files dialog box, use the Find/Replace in Files action that is available in the following locations:

The operation works on both local and remote files from an SFTP, WebDAV, or CMS server.

Find/Replace in Files Dialog Box

Figure 1. Find / Replace in Files Dialog Box (When Opened from the Toolbar Button)

The dialog box contains the following options:

Text to Find section

The first text field is where you enter the character string to search for. You can search for Unicode characters specified in the \uNNNN format. Also, hexadecimal notation (\xNNNN) and octal notation (\0NNNN) can be used. In this case you have to select the Regular expression option. For example, to search for a space character you can use the \u0020 code.

The rest of the options in this section can be used to refine your search:
Case sensitive
When selected, the search operation follows the exact letter case of the value entered in the Text to find field.
Whole words only
Only entire occurrences of a word are included in the search operation. This option is automatically disabled if either the Ignore extra whitespaces or Regular expression options are selected.
Restrict to XPath

The XPath 2.0 expression you input in this combo is used for restricting the search scope.

Example: Use the XPath filter expression //*[not(local-name() = 'uicontrol')] to skip over the contents of any <uicontrol> element.

Note:

Replace with section
Use the text field in this section to specify a character string to replace the target with. It may contain regular expression group markers if the search expression is a regular expression and the Regular expression checkbox is selected.
Tip:
If you want to change the XML structure, you could use the built-in XML refactoring operations. You can even customize your own refactoring operations.
Make backup files with extension
In the replace process Oxygen XML makes backup files of the modified files. The default extension is .bak, but you can change the extension as you prefer.
Scope section

The options available in this section depend on the context (how the dialog box was opened). Select one of the listed options to specify the scope for the operation. The possible options include:

Selected project resources
Searches only in the selected files.
Project files
Searches in all files from the current project.
All opened files
Searches in all files opened in Oxygen XML (regular files or DITA maps). You are prompted to save all modified files before any operation is performed.
Current file directory
The search is done in the directory of the file opened in the current editor panel. If there is no open file, this option is not available.
Current DITA Map hierarchy (only available if opened from the DITA Maps Manager)
The search is done in all maps and topics referenced by the currently selected DITA map, opened in the DITA Maps Manager view.
Selected references (only available if opened from the DITA Maps Manager)
Searches only in the selected DITA references.
Opened archive (only available if opened from the Archive Browser view)
The search is done in an archive opened in the Archive Browser view.
Specified path
Use this option to specify the search path.
Filters section

The options available in this section depend on the context (how the dialog box was opened) and they can be used to filter the search operation. The possible options include:

Include files
Narrows the scope of the operation only to the files that match the given filters. For example, you can choose to filter the search to only include files with a certain file extension (such as *.xml).
Recurse subdirectories
When selected, the search is performed recursively for the specified scope. The one exception is that this option is ignored if the scope is set to All opened files.
Recurse references (only available if opened from the DITA Maps Manager)
When selected, the search is performed recursively for the selected scope.
Include hidden files
When selected, the search is also performed in the hidden files.
Include archives
When selected, the search is also done in all individual file entries from all supported ZIP-type archives.
Show separate results for each search expression
When selected, the application opens a new tab to display the result of each new search expression. When the option is unchecked, the search results are displayed in the Find in Files tab, replacing any previous search results.
Always open selected results in Text mode
If selected, double-clicking results will always open the documents in Text mode (even if the particular document type is set to open in Author mode, by default). If not selected (default state), double-clicking results will open the documents in whatever editing mode is specified as the default for that document type. For example, by default, DITA documents will open in Author mode (as specified in the default framework configuration for DITA document types). Specialized XML documents such as XSLT or XML Schema will continue being opened in the Text editing mode.
Find All
Use the Find All button to execute the search operation. The results are displayed in a view that allows grouping the results as a tree with two levels.
Replace All
Use the Replace All button to execute the search operation and replace all occurrences with the specified string. When you replace a fragment of text, Oxygen XML offers an option to preview of the changes you make. The Preview dialog box is divided in two sections. The first section presents a list of all the documents containing the fragment of text you want to modify. The second section offers a view of the original file and a view of the final result. It also allows you to highlight all changes using the vertical bar from the right side of the view. The Next change and Previous change buttons allow you to navigate through the changes displayed in the Preview dialog box.
CAUTION:
Use the Replace All option with caution. Global searches may result in matching strings being replaced in instances that were not originally intended.
Note:
  • You can use Perl-like regular expression syntax to match patterns in text content. The replace operation can bind regular expression capturing groups ($1, $2, etc.) from the find pattern.
  • Exclusion patterns are accepted. For example, *.java, !*Test.java would search for all files with a .java extension, with the exception of any file whose name ends in Test.
  • To replace the <tag-name> start tag and its attributes with the <new-tag-name> tag use as Text to find the expression <tag-name(\s+)(.*)> and as Replace with the expression <new-tag-name$1$2>.
  • The encoding used to read and write the files is detected from the XML header or from the BOM. If a file does not have an XML header or BOM Oxygen XML uses by default the UTF-8 encoding for files of type XML, that is for files with one of the extensions: .xml, .xsl, .fo, .xsd, .rng, .nvdl, .sch, .wsdl or an extension associated with the XML editor type. For the other files it uses the encoding configured for non-XML files.
  • You can cancel a long operation at any time by pressing the Cancel button of the progress dialog box or in the status bar, but doing so will not revert any replacements that have been processed up to that point.
  • Since the content of read-only files cannot be modified, the Replace operation does not process those files. For every such file, a warning message is displayed in the message panel.