Skip to content

Add object selection (textobjects) - #385

Merged
archseer merged 13 commits into
helix-editor:masterfrom
sudormrfbin:textobject
Jul 3, 2021
Merged

Add object selection (textobjects)#385
archseer merged 13 commits into
helix-editor:masterfrom
sudormrfbin:textobject

Conversation

@sudormrfbin

@sudormrfbin sudormrfbin commented Jun 27, 2021

Copy link
Copy Markdown
Member

Closes #213.

helix-textobject-1

Uses ma (match around) and mi (match inside).

TODO

  • Objects
    • Word - maw, miw
    • Brackets (surround) - ma(, mi", 2ma[, etc
  • Docs
    • Usage
    • Keymaps

Future Work

@pickfire

Copy link
Copy Markdown
Contributor

While at this can you try to add ]p?

Comment thread helix-term/src/commands.rs
@sudormrfbin

Copy link
Copy Markdown
Member Author

@pickfire

While at this can you try to add ]p?

I assume you mean move to next paragraph (like } in vim; ]p in vim is paste with indent); I was thinking of adding similar motions for functions and classes based on treesitter. Will add it to my todo list 👍🏾

@pickfire

Copy link
Copy Markdown
Contributor

]p in kakoune and } in vim

Comment thread helix-core/src/movement.rs Outdated
Comment thread helix-core/src/movement.rs Outdated
@archseer

Copy link
Copy Markdown
Member

Feel free to land this without paragraph, etc. Those can come in a follow-up.

@sudormrfbin

Copy link
Copy Markdown
Member Author

Feel free to land this without paragraph, etc. Those can come in a follow-up.

I think that's better for now. I'll add the tests for the new word movements tomorrow and complete it :)

It's the same as PrevWordEnd except for taking the current char
into account, so use a "flag" to capture that usecase
They did not preserve anchor positions and were only used
for textobject boundary search anyway so replace them with
simple position finding functions
@sudormrfbin
sudormrfbin marked this pull request as ready for review July 2, 2021 06:42
Comment thread book/src/keymap.md Outdated
Comment thread helix-core/src/textobject.rs Outdated
@PabloMansanet

Copy link
Copy Markdown
Contributor

Can't find anything obviously wrong with this on a relatively shallow read. It looks good to me, so as longs as the test coverage is good and it's been manually tested, no complaints 👍

@cessen cessen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All-in-all this looks good to me. Not totally sure how I feel about the keybindings, but that's just bike-shedding. The functionality itself is good, and keybindings are probably best left to a holistic discussion of Helix's keymap.

@archseer

archseer commented Jul 3, 2021

Copy link
Copy Markdown
Member

Great work @sudormrfbin! 🎉

@archseer
archseer merged commit c68fe1f into helix-editor:master Jul 3, 2021
@sudormrfbin
sudormrfbin deleted the textobject branch July 3, 2021 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Object selection mode

5 participants