Finding and Replacing Text
Prev
Next

Finding and Replacing Text

The Find Text and Replace Text Dialogs

The Find and Replace Text dialogs in Kate are very much the same, except the Replace Text dialog offers the means of entering a replacement string along with a few extra options.

The dialogs offer the following common options:

Text to Find

This is where to enter the search string. The interpretation of the string depends on some of the options described below.

Regular expression

If checked, the search string is interpreted as a regular expression. A button for using a graphical tool to create or edit the expression will be enabled.

See Regular Expressions for more on these.

Case sensitive

If enabled, the search will be case sensitive.

Whole words only

If checked, the search will only match if there is a word boundary at both ends of the string matching, meaning neither an alphanumeric character, nor some other visible characters, nor a line end.

From cursor

If checked, the search will start at the current cursor position, otherwise it will start at the beginning of the document.

Find backwards

If checked, the search will look for the first match above the starting point, either the cursor position or the beginning of the document depending on the status of the From cursor option.

Selected text

This option is not available if no text is selected. If some text has been selected and the option is checked, the search string will be matched only against the selected text.

The Replace Text dialog offers some additional options:

Replace With

This is where to enter the replacement string.

Use placeholders

When regular expressions are enabled, you can select part of the searched text by enclosing it within parenthesis. Placeholders allow you to insert such text in the replacement string, similar to how backreferences are used in sed. When enabled, any occurrence of \N (where N is an integer number, e.g. \1, \2, ...) will be replaced with the corresponding string capture (parenthesized substring) from the search pattern. A button for listing all available string captures will also be enabled. You can click on any of the available string captures to include them in your replacement string.

Note

Placeholders can only be used when searching using regular expressions.

Prompt on replace

If checked, a small dialog will prompt you for what to do for each time a match is found. It offers the following options:

Replace

Use this button to replace the current match, which is selected in the editor. After the replacement, search for the next match automatically.

Replace & Close

Use this button to replace the current match, which is selected in the editor. After the replacement, close the dialog.

Replace All

Use this button to replace all matches without further prompt.

Find next

Use this button to skip replacing the current match and try to find the next one.

Close

Use this button to skip replacing the current match and close the dialog.

Finding Text

To find text, launch the Find Text dialog with Ctrl+F or from the Edit->Find... menu item, enter a search string, set the options as desired and hit the Find button.

If a match is found it is selected and the Find Text dialog is hidden. Finding further matches is very easy.

To find the next match in the search direction, use the Edit->Find Next command or press F3.

To find the next match in the opposite direction, use the Edit->Find Previous command or press Shift+F3.

If no match is found before reaching the document end (or beginning if you are searching backward), you will be asked if you want to continue the search from the other end of the document.

Replacing Text

To replace text, launch the Replace Text dialog using the Edit->Replace... command or the Ctrl+R shortcut, enter a search string and optionally a replace string, set the options as desired and hit the Replace button. If the replace string is empty, each match will be removed.

Tip

If you are using a regular expression to find the text to replace, you can employ placeholders to reuse text captured in parenthesized subpatterns of the expression.

Tip

You can do find, replace and ifind (incremental search) from the editor command line.

Finding text in multiple files

To search for text in multiple files at once, please refer to the Find in Files Panel section.

Prev
Next
Home


Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team