LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

fastmod

Fast, interactive codebase-wide find and replace

TLDR

Replace a string interactively across the current directory
$ fastmod "[old_string]" "[new_string]"
copy
Replace using a regex with multiline matching
$ fastmod -m "[pattern]" "[replacement]"
copy
Replace in a specific directory
$ fastmod "[old]" "[new]" [path/to/directory]
copy
Replace only in files with specific extensions
$ fastmod -e "[py,js]" "[old]" "[new]"
copy
Accept all replacements without prompting
$ fastmod --accept-all "[old]" "[new]"
copy
Preview matches without modifying files
$ fastmod --print-only "[old]" "[new]"
copy
Treat pattern as a literal string instead of regex
$ fastmod --fixed-strings "[old.string()]" "[new.string()]"
copy

SYNOPSIS

fastmod [options] pattern [replacement] [paths...]

DESCRIPTION

fastmod performs fast, interactive codemod operations across files. It searches for regex patterns and prompts for confirmation before each replacement, making bulk code changes safer.The tool uses the same regex engine as ripgrep for fast searching combined with interactive review of changes. By default, patterns are treated as regular expressions. If no replacement is given, fastmod deletes the matched text. If no paths are given, it searches the current directory recursively.During interactive mode, press y to accept, n to skip, e to edit the replacement, a to accept all remaining, or q to quit.

PARAMETERS

-m, --multiline

Enable multiline regex matching (dot matches newlines).
-i, --ignore-case
Case insensitive matching.
-e, --extensions exts
Comma-separated list of file extensions to process (e.g., py,js,ts).
--accept-all
Apply all replacements without interactive prompting.
--print-only
Show matches without modifying files.
-d, --dir path
Set the root search directory (default: current directory).
--glob pattern
Include/exclude files by glob pattern (prefix with ! to exclude).
--hidden
Include hidden files and directories in the search.
--fixed-strings, -F
Treat the pattern as a literal string, not a regex.
--count
Display the total number of matches/replacements.

CAVEATS

Uses Rust's regex syntax, which may differ from PCRE or POSIX regex in some edge cases. Interactive mode requires a terminal. When using --accept-all, changes are applied without confirmation -- use --print-only first to preview.

HISTORY

fastmod was developed at Facebook (Meta) as a tool for large-scale code modifications. It addresses the need for interactive, safe refactoring across massive codebases. Released as open source, it is written in Rust for performance.

SEE ALSO

sed(1), codemod(1), comby(1), rg(1)

Copied to clipboard
Kai