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

feat: add variable segment movements and textobject #8658

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gertqin
Copy link

@gertqin gertqin commented Oct 29, 2023

Hi,

I only discovered helix a few days ago, but I've already (more or less) switched over from nvim - so thanks for an awesome editor! 🙂

However, one plugin I really like in nvim is vim-textobj-variable-segment which makes it a lot easier to navigate variables in title/camel/snake-case and edit parts of it.

In this draft PR I have made a simple implementation of it in helix, i.e. added

  • move/extend_prev_partial_word_start (keybind H)
    • Ex let |VarInTitleCase => let |Var|InTitleCase => let Var|In|TitleCase
  • move/extend_next_partial_word_end (keybind L)
    • Ex let var_in_snake_case| => let var_in_snake|_case| => let var_in|_snake|_case
  • textobject partial word (keybind v in match inside/outside mode)
    • Ex let var_in_sn|ake_case => mav => let var_in|_snake|_case
    • Ex let var_in_sn|ake_case => miv => let var_in_|snake|_case

(I named everything partial_word in the code, because that's what I thought the vim plugin was called until I looked it up...)

Do you think these commands belong to the helix core? If that's the case then I'll add unit tests to the PR.

I'll also gladly rename partial_word to something better if you can think of something, and you probably also want to reserve the keys H and L for something else.. (I think the movements could be added without default keybindings).

@kirawi
Copy link
Member

kirawi commented Oct 29, 2023

Duplicate of #8147 (leave this open for the maintainers to see which solution is preferred)

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.

None yet

2 participants