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: added line-wise select mode #2637

Closed
wants to merge 2 commits into from

Conversation

lazytanuki
Copy link
Contributor

Hello there !

This PR adds an equivalent to vim's V-LINE mode, here called line-select mode, that I've always been missing in Helix.

It allows the user to select lines up and down while automatically flipping the selections when the range head crosses the anchor. It also handles count and goto start/end of file.

The commands are usable from any other mode.
line_select_demo
(the keymap in this GIF demo is old code, don't mind it !)

Thanks and have a good day !

@the-mikedavis
Copy link
Member

the-mikedavis commented Jun 1, 2022

This mode seems unnecessary to me.

You can extend lines down and up with extend_line (x) and extend_line_above (no default binding but can be mapped to something convenient like X). If you need more flexibility, you can enter select mode (v) and use j/k or the arrow keys to select up and down lines and then ensure the selection is extended to line bounds with extend_to_line_bounds (X).

But even if there's good reason to add a line-wise select mechanism, this should be implemented as a sticky menu like Z rather than a new mode.

@archseer
Copy link
Member

archseer commented Jun 1, 2022

I agree, there doesn't seem to be much benefit to just selecting a range then using X to expand to line bounds.

@pickfire
Copy link
Contributor

pickfire commented Jun 1, 2022

Yeah, I find it not being very useful feature wise since we can achieve similar things that can be done here, xxxxx should be sufficient, but instead of doing that, it may be better to navigate using treesitter (A-o) or paragraph (map).

@Mathspy
Copy link
Contributor

Mathspy commented Jun 1, 2022

You can extend lines down and up with extend_line (x) and extend_line_above (no default binding but can be mapped to something convenient like X). If you need more flexibility, you can enter select mode (v) and use j/k or the arrow keys to select up and down lines and then ensure the selection is extended to line bounds with extend_to_line_bounds (X).

Heck, I was wondering why extend_line_above wasn't a thing when I tried it, thanks for pointing it out! I also think it makes sense to have a default for it

@pickfire
Copy link
Contributor

pickfire commented Jun 1, 2022

Heck, I was wondering why extend_line_above wasn't a thing when I tried it, thanks for pointing it out! I also think it makes sense to have a default for it

For that, you can do vkkkkkkkX as an alternative. I don't know what key is good to be set as default.

@lazytanuki
Copy link
Contributor Author

Alright I understand.

@musjj
Copy link

musjj commented Oct 9, 2023

Can this PR potentially be re-considered? I believe that a true line-wise mode would be incredibly useful for composability. The only way to have line-wise select keybinds that is both symmetrical and composable is to use vkkkX and vjjjX.

Any other solution requires you to have different keybindings for selecting lines above and below. I think it's rather awkward & inelegant for a very primitive movement.

@objectiveryan
Copy link

These bindings create a poor-man's line-wise mode that you enter with X:

"C-x" = "extend_to_line_bounds"
X = { j = "@vj<esc><C-x>X", k = "@vk<esc><C-x>X" }

The trick is to make each command end with X so it puts you back in the "mode".
(This requires #4709)

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.

7 participants