Open
Description
Just an idea I'm kicking around.
Creating cursors based on matching/splitting with regex is great. What about creating cursors based on text objects?
Splitting the following into arguments by vi(
and splitting on ,
is great:
foo(x, y, z)
But what about this?
foo(x, bar(y, z), (a, b))
Text objects are good. Treesitter text objects are super smart. A few uses:
- Selecting all (top-level) arguments in an argument list
- selecting all quoted strings in a text paragraph
- select all sentences in a text paragraph
- selecting all list items in a list
I've got an initial implementation here. It splits a single visual selection. For the example above, it creates three selections:
foo(x, bar(y, z), (a, b))
- --------- ------
It is likely naive and fragile. It relies on the search capability of mini.ai so that e.g. vi"
will find quoted text to the right.
Thoughts? Am I missing something obvious?