helix
helix copied to clipboard
Keybind for Extend/shrink selection up and down
Implements #9079
The implementation should work better now. Especially when flipping the selection and starting on a empty line :) I am unsure about the behaviour of flipping the selection as soon as the selection is one line. e.g. JJK currently leaves us with the cursor on the line start instead of the end. How do you feel about that? I'm open to change that.
I don't mind as I can just use my personal branch for now. Hope it will get merged eventually as I see people asking about this behaviour frequently.
Wouldn't say that the lint improves readability of the code but it's fine either way I guess. Sorry for not checking beforehand
Nice that this made it in. In case people are looking for ways to bind this, the following is a clean way to integrate this in the default keymapping.
[keys.normal]
J = ["select_line_below"]
K = ["select_line_above"]
"A-j" = "join_selections"
"A-J" = "join_selections_space"
X = "remove_primary_selection"
x = "keep_selections"
"A-x" = "remove_selections"
[keys.select]
J = ["select_line_below"]
K = ["select_line_above"]
"A-j" = "join_selections"
"A-J" = "join_selections_space"
X = "remove_primary_selection"
x = "keep_selections"
"A-x" = "remove_selections"
The bonus is that X pairs ergonomically with C and ( and ).
As an addendum, I find it useful to map H/L to select everything to the left/right:
[keys.normal]
"H" = ["select_mode", "goto_line_start", "exit_select_mode"]
"L" = ["select_mode", "goto_line_end", "exit_select_mode"]
[keys.select]
"H" = ["goto_line_start"]
"L" = ["goto_line_end"]
The rationale for choosing H/J/K/L is that they represent directions, while holding shift is often associated with extending a selection (in mainstream text editing UI).