Find & Replace

There are a number of ways to search for text in Komodo:

To replace text, use the Open/Find Toolbar with the Replace option.

Additional features are available for:

Incremental Search

Use incremental search to quickly find a word or string in the file you are currently editing.

Find Dialog

The Find dialog box is a multi-purpose interface for finding and replacing text. It has the following options:

The interface changes as different options are selected, so that you only see fields and buttons that are relevant to your task.

Regex Searches

Selecting Regex will interpret the search string as a Python regular expression, and perform the search accordingly.

To the right of the "Find what:" field are two buttons which can help you compose your regular expression:

When used in conjunction with Replace, regular expression replacement sequences can be used in the "Replace with:" field (e.g. "\1", "\g<name>", etc.).

Case Sensitivity

The Smart case / Match case option is a three-way toggle:

Match Whole Words

With Word selected, search strings will only match if a whitespace occurs on either side of the string. For example, if the search string is "edit" and "Word" is selected, only occurrences of the word "edit" will be found. If it is not selected, "editing", "editor", "editorial" and "edited" could also be found.

Multiline

Selecting Multiline changes the "Find what:" field (and the "Replace with:" field if Replace is selected) with larger, multiline text boxes.

This makes it easier to paste in multiline blocks of text in these fields. The search text will only match if the line breaks are the same. Line breaks in the "Replace with:" field are likewise respected.

Scope

The "Search in:" drop list defines where the find or replace will happen. It contains the following options:

Selecting Files from this list opens additional fields allowing you to set the scope of your search in directories on your filesystem:

See also the Replace in Files section for a description of the Confirm and Undo options.

Actions

Once all the options for the Find or Replace are set, choose the action you wish to perform. The action buttons available will depend on which options have been selected:

Replace in Files

Globally replacing strings in multiple files can be daunting. Using a search string that matches more than what was intended, specifying an incorrect replacement string, or selecting the wrong starting directory for a recursive replacement can cause havoc.

Komodo's Replace in Files feature has a Confirm option which lets you check the substitutions before you apply them, and an Undo feature to revert the replacement if you make a mistake.

Confirming Changes

When "Search in: Files" is selected, the only action button available is Replace All. Beneath this button is a Confirm check box. This option adds an additional step to the replacement process which allows you to view changes before applying them, and "un-mark" specific changes you don't want to apply.

Confirm Replacements

The Confirm Replacements dialog box shows a list of all pending replacements from the Replace in Files operation. Each line shows:

Show Selected Changes previews all selected changes in the list. Use 'Shift'+'Click' or 'Ctrl'+'Click' to select multiple items.

Show Marked Changes previews all marked changes.

The preview window has the same format and options as Compare Files. The preview is in unified diff format, so it can be copied and saved as a patch.

Make Changes

Once you have confirmed that all pending replacements are correct, or un-marked the changes you do not want to include, click Make Changes.

Review and Undo

As Komodo makes the replacements, it outputs a log of the changes in a Find Results tab in the bottom pane. You can click on any of the changes to open the file in an editor tab at the appropriate line.

If you've made a mistake and would like to roll back all of the changes from the last Replace in Files operation, click the Undo Replacements button in the Find Results tab toolbar.

Find Results Tabs

Find Results tabs are opened in the Bottom Pane to display matches from Find All, Find in Files or Replace in Files operations.

Komodo can open two tabs, Find Results 1 and Find Results 2, which can be locked using the Lock button in their respective toolbars. New find or replace operations will not overwrite contents in a locked tab.

Komodo uses the first available tab for output. If both tabs are locked during subsequent find or replace operations, Komodo prompts you to unlock one of the tabs or cancel the action.

The Find Results tabs display columns for:

Double-click on any output line to jump to the relevant file and line in an editor tab.

The Find Results toolbar has buttons to:

Open/Find Toolbar

The Open/Find toolbar provides a quick way to open files and find strings. The toolbar is not displayed by default; to open it select View|Toolbars|Open/Find.

This toolbar has three fields:

The Find and in fields both keep a list of the most recently entered strings and file specifications.

If a file or directory is specified in the in field, matches will be displayed in a Find Results tab.

Press 'Esc' to return focus to the Komodo editor. All fields can be accessed via their associated key bindings.

Finding Functions: Function Search

The Function Search looks through the current document for the following constructs:

Use Code|Find Next Function or Code|Find Previous Function (or the associated key bindings) to cycle through the functions.

Use Code|Find All Functions to display a list of all functions in a Find Results tab. Double-click on any entry to jump to the relevant line.