Find and replace

Search the active source view with Ctrl+F (Cmd+F on macOS). Open replacement controls with Ctrl+R (Cmd+R on macOS). The toolbar starts with selected text when you open it from a selection. Click Find on the source editor toolbar to show or hide Find and Replace.

Find and Replace toolbar showing three matches for COUNT and TOTAL in the replacement field

Use Match case to distinguish uppercase and lowercase letters. Whole word excludes matches next to a letter, digit, or underscore. Regex interprets the query as a regular expression.

Find text

Type a query to see the number of matches in the active view. The count is a total, not the position of the selected match. Select the arrows, press F3 for the next match or Shift+F3 for the previous match, or use Edit → Find next / Find previous. Navigation wraps at the end of the search boundary. Pressing Enter in the find field also selects the next match.

Select text in the editor to limit search and replacement to that selection. With a column or multiple selection, the search covers each selected range and skips the gaps. Moving between matches keeps the same search boundary. Select different text to change the boundary, or click in the editor to clear the selection and search the entire document, including unsaved edits.

Replace text

Enter a query and replacement. Leave Replace with empty to delete matching text. Replace changes the selected match and moves to the next one. If no match is selected, it selects the next match. Replace All changes all matches within the search boundary in one undo step. The status shows N replaced until you use another search action or switch source views.

Preserve case changes the replacement to follow each match. For example, replacing cat with dog changes cat to dog, CAT to DOG, and Cat to Dog. Other mixed capitalization is left as entered. This option controls replacement; Match case controls which text is found.

Regular expressions and groups

Enable Regex to use Java regular expressions. Without it, search treats the query as literal text. For example, cp* matches c followed by zero or more p characters, so it also matches the c in backspace. Use cp.* to match cp followed by the rest of the line. Use cp+ to require at least one p.

Use parentheses to capture text and refer to it in the replacement with $1, $2, and so on; $0 refers to the whole match. For example, find (first) (last) and replace with $2, $1 to produce last, first. Named groups also work: find (?<word>\w+) and use ${word} in the replacement. An unmatched optional group expands to an empty string. In a regex replacement, escape a literal dollar sign as \$ and a literal backslash as \\.

Invalid patterns and replacement group references show an error in the bar. Correct the query or replacement before continuing. Closing the bar keeps its query available to the next/previous search commands.


This site uses Just the Docs, a documentation theme for Jekyll.