Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
igncp committed Nov 28, 2017
1 parent 2c99655 commit 6bcf984
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Search and replace for the command line

**This package is under active development. The package name is provisional and the API may have breaking changes**

It provides a productive way of replacing strings in files via command line, including the following features:
- Replace matches one by one, viewing the diff, and updating the diff each time a change is made to a file
- Use regular expressions, which accept matched groups in the replacements, using `String.prototype.replace` under the hood
Expand All @@ -17,7 +19,25 @@ It requires Node v6.10 or higher

This package uses Node for everything, and it will be slower than other alternatives using C, Go, Rust, etc. The goal of this package is not maximize performance, but the features listed above. The speed in medium project sizes (less than 100k lines) is acceptable. PRs to improve the performance are always welcome.

**This package is under active development. The package name is provisional and the API may have breaking changes**
The controls when using the list UI are:

- Exit: `q` or `control-c`
- Scroll preview: `right` and `Page-Up` or `Page-down`
- Replace: `Enter`

## Examples

A simple replacement command with a list UI:

`sr searchPath 'a regex*? search pattern' 'a search replacement'`

You can't use `sr` with pipes because the terminal UI would not work. However, you can use command substitution:

`sr <(find docs -type f -name "*.md") searchPattern searchReplacement`

If you don't want any UI and just want the matches replaced:

`sr --disable-list path searchPattern searchReplacement`

## License

Expand Down

0 comments on commit 6bcf984

Please sign in to comment.