Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add section for experimental custom regex scopes to customization.md #2315

Merged
merged 12 commits into from
May 1, 2024
34 changes: 34 additions & 0 deletions docs/user/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,40 @@ push down, editor.action.moveLinesDownAction

Now when you say eg "push down air and bat", cursorless will first select the two tokens with a gray hat over the `a` and `b`, then issue the VSCode command `editor.action.moveLinesDownAction`, and then restore your original selection.

## \[Experimental\] Cursorless custom regex scopes

You can define custom scopes using regexes in `user/cursorless-settings/experimental/regex_scope_types.csv`

:::tip

Use `"visualize <scope>"` to see a live preview of the regex scope in [the scope visualizer](./scope-visualizer.md). It updates in real time every time you save `regex_scope_types.csv`.

:::

For example, here's what `"visualize dotted"` would show with the scope type `dotted,"[\w.]+"`:

<div class="light-mode-invert">
![visualization of a custom regex scope](./images/custom-regex-scopes.png)
</div>

You can then use commands such as

- `"take dotted sun"` to select `user.text` (line 10)
- `"copy dotted urge"` to copy `user.chrome_mod` (line 11)
- `"take every dotted urge"` to select `user.chrome_mod`, `shift`, and `a`

:::tip

> Check out [our wiki page](https://github.com/cursorless-dev/cursorless/wiki/Custom-regex-scopes) for a recipe book of user-created regex scopes!

:::

:::warning

Regex matches cannot cross line boundaries (so multiline matches are not supported). The regexes also have the unicode flag set.

:::

CodesAway marked this conversation as resolved.
Show resolved Hide resolved
## Toggling "hat" display

It is possible to show / hide the hats with a command. Keep in mind that many users, often after less than a week using Cursorless, find that their brain starts to tune out the hat display. Some start to miss them when they're gone 🥲
Expand Down
Binary file added docs/user/images/custom-regex-scopes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/cursorless-org-docs/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
[data-theme="dark"] .dark-mode-invert {
filter: invert(90%) hue-rotate(180deg);
}

[data-theme="light"] .light-mode-invert {
filter: invert(90%) hue-rotate(180deg);
}
Loading