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 object selection (textobjects) #385

Merged
merged 13 commits into from
Jul 3, 2021

Conversation

sudormrfbin
Copy link
Member

@sudormrfbin sudormrfbin commented Jun 27, 2021

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
Contributor

While at this can you try to add ]p?

@sudormrfbin
Copy link
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
Contributor

]p in kakoune and } in vim

@archseer
Copy link
Member

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

@sudormrfbin
Copy link
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
book/src/keymap.md Outdated Show resolved Hide resolved
@PabloMansanet
Copy link
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 👍

Copy link
Contributor

@cessen cessen left a comment

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
Copy link
Member

archseer commented Jul 3, 2021

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