Finding and Replacing Text in Multiple Files

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 (S)FTP, WebDAV or CMS server.

It enables you to define Search for or Search for and Replace operations across a number of files. 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.

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 Editor 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 displayed when the operation is executed.

Since the content of read-only files cannot be modified, the Replace operation is not processing those files. For every such file, a warning message is displayed in the message panel.

Figure: Find / Replace in Files Dialog Box

The dialog box contains the following options:

When you replace a fragment of text, Oxygen XML Editor provides a 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 this option with caution. Global search and replace across all project files does not open the files containing the targets, nor does it prompt on a per occurrence basis, to confirm that a replace operation must be performed. As the operation simply matches the string defined in the find field, this may result in replacement of matching strings that were not originally intended to be replaced.