Search and replace, TUI style. Mirror available on Codeberg.
See the codeswpui (pronounced "swap UI") is a TUI utility to search and replace text, with a focus on ergonomics, speed and
case-awareness in source code.
Dual-licensed under MIT or Apache 2.0.
cargocargo install swpui
cargo-binstallcargo binstall swpui
nixpkgs-unstable)nix profile install nixpkgs#swpui
Or run without installing:
nix run nixpkgs#swpui
Head over to the releases page!
$ swp
| Key | Action |
|---|---|
Tab | Next pane |
Shift+Tab | Previous pane |
Ctrl+r / Alt+r | Cycle match mode |
Ctrl+g / Alt+g | Toggle glob filter view |
Ctrl+o / Alt+o | Open options menu |
Ctrl+c | Quit |
| Key | Action |
|---|---|
r | Cycle match mode |
h | Toggle hidden files |
g | Toggle gitignored files |
Esc / Ctrl+o / Alt+o | Close options menu |
| Key | Action |
|---|---|
j / Down | Next file |
k / Up | Previous file |
l / Enter / Right | Focus preview pane |
s / Space | Skip all matches in file (toggle) |
f | Apply replacement to file |
a | Apply replacement to all files |
q | Quit |
| Key | Action |
|---|---|
j / Down | Next match |
k / Up | Previous match |
Space | Skip selected match (toggle) |
Enter | Apply replacement for selected match |
h / Esc / Left | Back to file list |
s | Skip all matches in file (toggle) |
f | Apply replacement to file |
q | Quit |
| Key | Action |
|---|---|
Esc | Focus file list |
In regex mode, the replacement template can reference capture groups from the search pattern using $0 through $9:
$0 expands to the entire match.$1-$9 expand to the corresponding capture groups (parenthesized sub-expressions in the pattern).$$ produces a literal $.For example, searching for (\w+)_(\w+) and replacing with $2_$1 swaps the two halves of each snake_case pair.
Press Ctrl+g / Alt+g to switch to the glob filters view. The search and replace fields are hidden in favor of a
field for and "include" and "exclude" globs list. Each input takes a comma-separated list of globs with
gitignore matching semantics (same as ripgrep's -g flag).
Filters combine with the hidden/gitignore options and .swpignore files (an include glob does not re-include an ignored
file). Active filters are shown in the status line at the bottom.
Default values for the options can be persisted in a swpui.toml (or .swpui.toml) file. On startup, swpui looks for
them in:
~/.config/swpui/ on Linux and macOS, %APPDATA%\beeb\swpui\ on Windows).swpui was launched.Settings closer to the working directory override settings from parents, and any field omitted from a file falls back to the value from the next layer up, ultimately defaulting to the built-in defaults shown below:
[options]
match-mode = "case-aware" # case-aware | literal | regex | regex-multiline
include-hidden = true
include-gitignored = false
include-globs = [] # e.g. ["src/**", "*.{rs,toml}"]
exclude-globs = [] # e.g. ["*_test.rs"]
In addition to .gitignore and .ignore files, swpui honors .swpignore files. These use the same
gitignore syntax and are scoped per-directory: a .swpignore placed in any
directory applies to that directory and its descendants.
.swpignore filesThis tool was inspired by serpl, thanks for the great idea! It would also not have been possible without the amazing work put into ratatui and rat-widget, thank you! Finally, a massive thanks to the creator of ripgrep for their awesome work on ignore and regex.
112 commits
15 commits
Rust
99.3%
Search and replace, TUI style. Mirror available on Codeberg.
See the codeswpui (pronounced "swap UI") is a TUI utility to search and replace text, with a focus on ergonomics, speed and
case-awareness in source code.
Dual-licensed under MIT or Apache 2.0.
cargocargo install swpui
cargo-binstallcargo binstall swpui
nixpkgs-unstable)nix profile install nixpkgs#swpui
Or run without installing:
nix run nixpkgs#swpui
Head over to the releases page!
$ swp
| Key | Action |
|---|---|
Tab | Next pane |
Shift+Tab | Previous pane |
Ctrl+r / Alt+r | Cycle match mode |
Ctrl+g / Alt+g | Toggle glob filter view |
Ctrl+o / Alt+o | Open options menu |
Ctrl+c | Quit |
| Key | Action |
|---|---|
r | Cycle match mode |
h | Toggle hidden files |
g | Toggle gitignored files |
Esc / Ctrl+o / Alt+o | Close options menu |
| Key | Action |
|---|---|
j / Down | Next file |
k / Up | Previous file |
l / Enter / Right | Focus preview pane |
s / Space | Skip all matches in file (toggle) |
f | Apply replacement to file |
a | Apply replacement to all files |
q | Quit |
| Key | Action |
|---|---|
j / Down | Next match |
k / Up | Previous match |
Space | Skip selected match (toggle) |
Enter | Apply replacement for selected match |
h / Esc / Left | Back to file list |
s | Skip all matches in file (toggle) |
f | Apply replacement to file |
q | Quit |
| Key | Action |
|---|---|
Esc | Focus file list |
In regex mode, the replacement template can reference capture groups from the search pattern using $0 through $9:
$0 expands to the entire match.$1-$9 expand to the corresponding capture groups (parenthesized sub-expressions in the pattern).$$ produces a literal $.For example, searching for (\w+)_(\w+) and replacing with $2_$1 swaps the two halves of each snake_case pair.
Press Ctrl+g / Alt+g to switch to the glob filters view. The search and replace fields are hidden in favor of a
field for and "include" and "exclude" globs list. Each input takes a comma-separated list of globs with
gitignore matching semantics (same as ripgrep's -g flag).
Filters combine with the hidden/gitignore options and .swpignore files (an include glob does not re-include an ignored
file). Active filters are shown in the status line at the bottom.
Default values for the options can be persisted in a swpui.toml (or .swpui.toml) file. On startup, swpui looks for
them in:
~/.config/swpui/ on Linux and macOS, %APPDATA%\beeb\swpui\ on Windows).swpui was launched.Settings closer to the working directory override settings from parents, and any field omitted from a file falls back to the value from the next layer up, ultimately defaulting to the built-in defaults shown below:
[options]
match-mode = "case-aware" # case-aware | literal | regex | regex-multiline
include-hidden = true
include-gitignored = false
include-globs = [] # e.g. ["src/**", "*.{rs,toml}"]
exclude-globs = [] # e.g. ["*_test.rs"]
In addition to .gitignore and .ignore files, swpui honors .swpignore files. These use the same
gitignore syntax and are scoped per-directory: a .swpignore placed in any
directory applies to that directory and its descendants.
.swpignore filesThis tool was inspired by serpl, thanks for the great idea! It would also not have been possible without the amazing work put into ratatui and rat-widget, thank you! Finally, a massive thanks to the creator of ripgrep for their awesome work on ignore and regex.
112 commits
15 commits
Rust
99.3%