aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-23 09:49:26 +0000
committerGitHub <[email protected]>2020-02-23 09:49:26 +0000
commitdea1d957e5fec51e8210b3fc4d2db7099d0ff000 (patch)
treeec1df155793408be2dcd80b5a498607da01f85a2
parent1651ce0ebe1cf1d51541a04457f72595d669c967 (diff)
parent28367f7e4fc0771c9ee2a01163db0f632ea6600b (diff)
Merge #3275
3275: Add Structural Search and Replace doc r=matklad a=adamrk Addresses the first point of https://github.com/rust-analyzer/rust-analyzer/issues/3186. Co-authored-by: adamrk <[email protected]> Co-authored-by: Adam Bratschi-Kaye <[email protected]>
-rw-r--r--docs/user/features.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/user/features.md b/docs/user/features.md
index a9cff34d2..48c63ba7b 100644
--- a/docs/user/features.md
+++ b/docs/user/features.md
@@ -105,6 +105,21 @@ Start `cargo watch` for live error highlighting. Will prompt to install if it's
105 105
106Stop `cargo watch`. 106Stop `cargo watch`.
107 107
108#### Structural Seach and Replace
109
110Search and replace with named wildcards that will match any expression.
111The 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
117String::from(foo(y + 5, z))
118
119// AFTER
120String::from((y + 5).foo(z))
121```
122
108### Assists (Code Actions) 123### Assists (Code Actions)
109 124
110Assists, or code actions, are small local refactorings, available in a particular context. 125Assists, or code actions, are small local refactorings, available in a particular context.