Skip to content

Commit dea1d95

Browse files
bors[bot]adamrk
andauthored
Merge #3275
3275: Add Structural Search and Replace doc r=matklad a=adamrk Addresses the first point of #3186. Co-authored-by: adamrk <[email protected]> Co-authored-by: Adam Bratschi-Kaye <[email protected]>
2 parents 1651ce0 + 28367f7 commit dea1d95

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/user/features.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,21 @@ Start `cargo watch` for live error highlighting. Will prompt to install if it's
105105

106106
Stop `cargo watch`.
107107

108+
#### Structural Seach and Replace
109+
110+
Search and replace with named wildcards that will match any expression.
111+
The syntax for a structural search replace command is `<search_pattern> ==>> <replace_pattern>`. A `$<name>:expr` placeholder in the search pattern will match any expression and `$<name>` will reference it in the replacement. Available via the command `rust-analyzer.ssr`.
112+
113+
```rust
114+
// Using structural search replace command [foo($a:expr, $b:expr) ==>> ($a).foo($b)]
115+
116+
// BEFORE
117+
String::from(foo(y + 5, z))
118+
119+
// AFTER
120+
String::from((y + 5).foo(z))
121+
```
122+
108123
### Assists (Code Actions)
109124

110125
Assists, or code actions, are small local refactorings, available in a particular context.

0 commit comments

Comments
 (0)