feat: add variable segment movements and textobject #8658
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
(keybindH
)let |VarInTitleCase
=>let |Var|InTitleCase
=>let Var|In|TitleCase
move/extend_next_partial_word_end
(keybindL
)let var_in_snake_case|
=>let var_in_snake|_case|
=>let var_in|_snake|_case
partial word
(keybindv
in match inside/outside mode)let var_in_sn|ake_case
=> mav =>let var_in|_snake|_case
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 keysH
andL
for something else.. (I think the movements could be added without default keybindings).