Skip to content

feat: add variable segment movements and textobject#8658

Closed
gertqin wants to merge 2 commits intohelix-editor:masterfrom
gertqin:partial-word
Closed

feat: add variable segment movements and textobject#8658
gertqin wants to merge 2 commits intohelix-editor:masterfrom
gertqin:partial-word

Conversation

@gertqin
Copy link
Copy Markdown

@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
Copy Markdown
Member

kirawi commented Oct 29, 2023

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

@RoloEdits
Copy link
Copy Markdown
Contributor

#8147 was merged, this can now be closed

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.

4 participants