Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/untitaker/spacemod
An easy to understand and powerful text search-and-replace tool
https://github.com/untitaker/spacemod
codemod grep refactoring refactoring-tools rust search-and-replace
Last synced: 15 days ago
JSON representation
An easy to understand and powerful text search-and-replace tool
- Host: GitHub
- URL: https://github.com/untitaker/spacemod
- Owner: untitaker
- License: mit
- Created: 2020-11-21T16:33:19.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-21T09:51:58.000Z (8 months ago)
- Last Synced: 2024-10-21T06:20:05.924Z (22 days ago)
- Topics: codemod, grep, refactoring, refactoring-tools, rust, search-and-replace
- Language: Rust
- Homepage: https://untitaker.github.io/spacemod/
- Size: 194 KB
- Stars: 44
- Watchers: 3
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spacemod
`spacemod` is a text search-and-replace tool optimized towards refactoring
code.```python
# example.py (before)
copy_file(to_file=to_file, from_file=from_file)copy_file(
to_file=get_file(filepath, mode),
from_file=get_file_writer(other_filepath, other_mode)
)
``````sh
# Use spacemod's custom pattern-matching language to deal with whitespace easier.
# Without -S, normal regex patterns are assumed.$ spacemod -S \
'copy_file ( to_file= (.*) , from_file= (.*) )' \
'copy_file($2, $1)' \
example.py# spacemod will open interactive TUI and ask for approval of diffs. Use
# --accept-all to use spacemod non-interactively.
``````python
# example.py (after)
copy_file(from_file, to_file)copy_file(get_file_writer(other_filepath, other_mode)
, get_file(filepath, mode))
```It is very similar to [fastmod](https://github.com/facebookincubator/fastmod),
but with some additional features:* **Undo stack.** Approved a diff too soon? Hit `[u]ndo` to revert.
* **Yes to all diffs like this.** Auto-approve future diffs with the exact same content.
* **Parenthesis-matching (experimental).** Besides regex, spacemod also
supports a custom regex-like language that requires less escaping and
whitespace-handling.## Installation
Check [the website](https://untitaker.github.io/spacemod/) for installation options.
## Matching Modes
By default, you use regexes to replace text. See [Matching
modes](./docs/matching.md) for the alternative modes that `spacemod` supports.## Alternatives
There are many tools like `spacemod`, some of which may suit your needs better. Take a look at [Alternatives](./docs/alternatives.md).
## License
Licensed under `MIT`, see [`./LICENSE`](./LICENSE).