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.
Each new search starts in regex mode. Press Alt-r in the search prompt to toggle
literal matching: foo.bar then matches a dot rather than any character. The
prompt shows [regex] or [literal]; toggling leaves the input unchanged. Literal
mode also accepts unmatched brackets and other regex punctuation as ordinary text.
History navigation (Up/Down or Ctrl-p/Ctrl-n) restores both the entered text
and its syntax. Returning from history restores the draft’s text and syntax.
Enter in an empty prompt repeats the previous search with its original syntax;
Right inserts that search for editing. Tab completes history entries in the
current syntax. n and N preserve literal matching after the prompt closes.
The search register exposes an escaped regex pattern for literal searches, so
existing register-based commands continue to work.
The toggle action can be remapped as toggle_search_syntax under [keys.prompt].
It applies to buffer search prompts; selection regex prompts and project search
keep their existing syntax.
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 also highlight visible matches, while keeping the selected result’s line highlighted.
Browse matches in the current buffer
To open the buffer search picker, add a binding in config.toml:
[keys.normal.space]
L = "search_picker_in_current_buffer"
[keys.select.space]
L = "search_picker_in_current_buffer"
Press Space L and enter a regular expression. Each match has its own row with
a line and column number. Press Enter to select the match. The picker searches
the current buffer, including unsaved edits and scratch buffers.
Press Alt-c to toggle case sensitivity, or Ctrl-q to copy the results to the
quicklist. Space ' reopens the picker for the same buffer.
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.