Replace text using multiple rules in CotEditor on Mac

The Multiple Replace feature applies multiple text replacements sequentially. You can save each set of replacement rules as a named definition and reuse it whenever needed.

Open the Multiple Replace window

Use the Multiple Replace window to manage and perform text replacements in your document.

  1. Go to the CotEditor app on your Mac.

  2. Choose Find > Multiple Replace.

Screenshot of the Multiple Replace window

Manage replace definitions

Stored replace definitions appear in the list in the sidebar.

In the sidebar, do any of the following:

Export and import replace definitions

You can export replace definitions to transfer them to another computer. Each definition is saved as a CotEditor replace definition file with the .cotrpl extension. The file content is written in JSON format.

Import TSV data as replace definitions

You can also create a replace definition from a UTF-8–encoded TSV file. Each line must contain a pair of search and replacement text separated by a tab. To import this format, choose a file with the .tsv extension using the Import command. This format doesn’t support options such as case sensitivity or regular expressions. After importing a TSV file, configure any required options manually.

Edit a replace definition

To edit a replace definition in the right pane of the Multiple Replace window, do any of the following:

Changes save automatically as you work.

For each replacement rule, you can configure the following options:

OptionDescription
(checkbox)

If the checkbox is deselected, the rule is skipped. Use this option to temporarily disable a rule without removing it from the definition.

Find

The text to search for. This field can’t be left empty. Empty rules are considered invalid and skipped.

Replace With

The replacement text. If left empty, the matched text is removed.

RE

Search using regular expressions (abbreviation of Regular Expression).

IC

Search ignoring case (abbreviation of Ignore Case).

Description

Add a note for your reference. The description doesn’t affect replacement and can be left blank.

Replacement rules are applied sequentially from top to bottom.

Note: If a rule is invalid, it is skipped when replacements are performed.

Perform multiple replacements

To perform multiple replacements using a replace definition, do the following:

  1. In the CotEditor app on your Mac, open a document.

  2. Choose Find > Multiple Replace.

  3. Do one of the following:

    • Choose the replace definition in the Multiple Replace submenu.

    • Choose Manage Multiple Replace, select the replace definition to use in the sidebar, then click Replace All.

Highlight matches using a multiple replace definition

You can also highlight all matches in the current document using a multiple replace definition.

  1. In the CotEditor app on your Mac, open a document.

  2. Choose Find > Multiple Replace > Manage Multiple Replace.

  3. Select the replace definition to use in the sidebar.

  4. Click Highlight.

Note: Highlighted matches may differ from the actual replacement results. This is because Replace All applies rules sequentially, and each rule is applied after the previous rules have already taken effect.

See also