docs.kde.org
Finding and Replacing Text
Prev
Next

Finding and Replacing Text

The Search and Replace Bars

Kate has an incremental search bar and a power search and replace bar, which offers the means of entering a replacement string along with a few extra options.

The bars offer the following common options:

Find

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

Highlight all

If enabled, all matches in the whole document are highlighted.

Match case

If enabled, the search will be limited to entries that match the case (upper or lower) of each of the characters in the search pattern.

From cursor

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

The power search and replace bar offers some additional options:

Plain Text

Literally match any occurrence of the search string.

Whole Words

If selected, the search will only match if there is a word boundary at both ends of the string matching, meaning not an alphanumeric character - either some other visible character or a line end.

Escape Sequences

If selected, the Add button will be enabled and allows you to add escape sequences to the search pattern from a predefined list.

Regular Expression

If selected, the search string is interpreted as a regular expression. The Add button will be enabled and allows you to add regular expression items to the search pattern from a predefined list.

See Regular Expressions for more on these.

Selection only

If checked, the search and replace will be performed within the selected text only.

Finding Text

To find text, launch the incremental search bar with Ctrl+F or from the Edit->Find... menu item.

This opens the incremental search bar at the bottom of the editor window. On the left side of the bar is an icon to close the bar, followed by a small text box for entering the search pattern.

When you start entering characters of your search pattern, the search starts immediately. If there is a match in the text this is highlighted and the background color of the entry field changes to light green. If the search pattern does not match any string in the text, this is indicated by a light red background color of the entry field and Not found is displayed at the right side of the bar.

Use the Next or Previous button to jump to the next or previous match in the document.

You can modify the search behaviour by selecting the different Options described above.

Click on the green arrow icon at the right side of the incremental search bar to switch to the power search and replace bar.

To repeat the last find operation, if any, without calling the incremental search bar, use Edit->Find Next (F3) or Edit->Find Previous (Shift+F3).

Replacing Text

To replace text, launch the power search and replace bar using the Edit->Replace command, or the Ctrl+R shortcut.

On the upper left side of the bar is an icon to close the bar, followed by a small text box for entering the search pattern.

You can control the search mode by selecting the options Plain Text, Whole Words, Escape Sequences or Regular Expression described above.

Use the Next or Previous button to jump to the next or previous match in the document.

Enter the text to replace with in the text box labelled Replace and click the Replace button to replace only the highlighted text or the Replace All button to replace the search text in the whole document. If the option Use placeholders is checked you can add special items to the replacement text by clicking the Add button.

You can modify the search and replace behaviour by selecting the different options on the right side of the bar.

Click on the green arrow icon at the right side of the power search and replace bar to switch to the incremental search bar.

Tip

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

See Appendix B, Regular Expressions for more on those.

Tip

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

Prev
Next
Contents


docs.kde.org