Search and replacement
Find text in a file
Press /, type a regular expression, and press Enter. Use n and N to
select the next and previous matches. ? starts a backward search.
To search for selected text, press *, then n. Mitos treats the text
literally and adds word boundaries where appropriate. Use Alt-* to search
without adding word boundaries.
Search ignores case unless the pattern contains an uppercase letter. It wraps
at the end of a file by default. Change either behavior in
editor.search.
Buffer search matches use the theme’s ui.cursor.match style. The active
selection keeps its selection style. Highlights remain after confirming a search
and clear when the document changes. Canceling restores the previous highlights;
empty or invalid input clears the preview. Confirming an empty prompt repeats
the previous search.
Highlighting covers complete visible source lines, including horizontally scrolled text. Multiline matches crossing the viewport boundary or a fold may be omitted. Workspace search and replacement previews retain their existing result-line highlighting.
Replace several matches
- Press
%to select the whole file, or select the region you want to edit. - Press
s, type the regular expression, and pressEnter. - Press
Alt-r, type the replacement, and pressEnter.
Each match becomes a separate selection. The replacement applies to all of
them in one undo step. Esc cancels the replacement; an empty replacement
deletes the selected text. Replacement text is literal: $1 does not expand a
regex capture. The new text stays selected. Press , to keep one selection,
or . to repeat the replacement on other selections.
Use c instead of Alt-r to edit the matches interactively in insert mode.
The r command replaces every selected character with one character:
selecting hello and pressing rx gives xxxxx; replacing it with Alt-r
and x gives x.
For an edit across several lines, Alt-s first creates one selection per
line. K keeps selections matching a regex; Alt-K removes matching
selections. See Selections for more examples.
Search a project
Press Space / to open global search and enter a regular expression. Press
Enter to open a result. Use Space ' to return to the results.
Filter paths by adding %path (or %p) to the query. For example,
TODO %p .rs searches for TODO in matching Rust file paths. Path filters use
fuzzy matching; see picker filters.
To search for the current selection, press *, then Space /, then Enter
without entering another query. Global search follows the
file-picker ignore settings.
Press Ctrl-q in the results to collect their locations in the
quicklist. After closing the picker, use ]q and [q to
visit each result and edit it. The selection replacement workflow above
operates within the current buffer.
To replace across files directly, press Alt-r in global search and enter a
replacement. Enter replaces one match; Ctrl-Enter replaces all occurrences
in the files matching the current path filter. Global replacement expands regex
captures. Existing buffers stay unsaved; unopened files are updated directly on
disk. See Replacing global search results.