-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Keymap change proposal: extending lines in both directions #2130
Comments
So, EDIT: why not just let |
Typed this up at 3am sorry about the confusing jargon. "At bounds" means the whole line is already selected (cursor heads and anchor are at the boundaries of the line). I thought it would be nice and consistent if x was essentially the "by line motion command", so it should advance a line in SEL as well as NOR. |
I thought of an edge case I did not cover, which is if you have two selections, one of which covers the whole line and the other of which does not. I feel like in this instance a single press of either |
An optional extension to this could be to add |
I've edited the description to take into account clarifications and additions from conversation up to this point. |
I like the The current
|
This would be covered by
I have been observing a lot of people in matrix make the request for moving up, but I see your perspective as well. In my view, if you want to move the bottom of the select upwards (as opposed extend to additional lines on top), that's a good use case for |
I've updated the description to include an example keymap and asciinemas of the proposal in action for easier consideration. |
Another option is to bind an eventual As for mapping |
That said, I understand that people are used to being able to mash
👍 |
I've expressed my opinion about this before that I personally really don't like the inconvenience this introduces. The current behaviour of |
I don't think it's confusing that
For more fine grained control like you're describing (ie moving upward bounds of the selection down and downward bounds up), I think it's reasonable to enter select mode. |
I don't think hitting The existing So, my suggestion would be to go all in on
To make that last one even shorter, we could map
You could also map
EDIT: to try it out [keys.normal]
"x" = "extend_to_line_bounds"
"X" = "copy_selection_on_next_line"
"D" = ["extend_to_line_bounds", "delete_selection"]
"C" = ["extend_to_line_bounds", "change_selection"]
"Y" = ["extend_to_line_bounds", "yank"]
[keys.select]
"x" = "extend_to_line_bounds"
"X" = "copy_selection_on_next_line"
"D" = ["extend_to_line_bounds", "delete_selection"]
"C" = ["extend_to_line_bounds", "change_selection"]
"Y" = ["extend_to_line_bounds", "yank"] |
Closing as this never gained traction and there are arguably too many users nowadays for fundamental changes like this. |
Context and Motivation
There have been a few discussions regarding the behavior of
x
in various places (#165, #1638), but it feels like maybe the community is starting to trend in a particular, actionable direction (judging by matrix discussion, new user input, and recent change in kakoune) that I would like to propose in isolation here.Goals
x
(commonly requested)x
accessible (people seem to like it as a shortcut/cheat rather than puzzling out which textobject or tree-sitter nav would work best in a given situation)Dependencies
Proposed Change
Terminology
"At bounds" refers to when all selections have their head/cursor/selection start and anchor/selection end on the first or last character (not including the newline) of any line.
NORMAL Mode (not at bounds)
x
= extend to line bounds, ensure cursor forwardX
= extend to line bounds, ensure cursor reverseAlt-x
= extend to line bounds, do not alter selection directionNORMAL Mode (at bounds)
x
= select next full line (not extending), cursor forwardX
= select previous full line (not extending), cursor reverseAlt-x
= extend to line bounds, do not alter selection directionSELECTION Mode (not at bounds)
Same as NORMAL (not at bounds)
SELECTION Mode (at bounds)
x
andX
same as NORMAL (at bounds), but extendingAlt-x
= add one line above and below, do not alter selection directionConfiguration for Testing
Add this to your
config.toml
in combination with running from the #2117 PR in order to see 95% how this would work as described above. The caveat being that the intelligent behavior of only extending the current selections to line bounds on the first press doesn't work as intended for most invocations, as there is no detection possible without code alteration.See it in action
Here are some examples of the above config in action, keeping in mind the caveats.
x
andX
in NORMAL:x
andX
in SELECTION:Alt-x
in NORMAL:Alt-x
in SELECTION:Considerations
I think this has a lot of nice properties, such as symmetry and a good interaction with SELECTION mode. I'll add examples tomorrow that showcase them. It does however introduce the need to switch to SELECTION to reproduce the current behavior. This could also be a good thing as it builds habits that transfer to other motion commands. I also chose not to bind the current behavior of
X
to any key, as its existence seems more tied to its historical use in consistency while scripting kakoune than any practical use case (the functionality is available just not idempotently).Alternative Proposal
NORMAL (at bounds)
x
= add line below to selection (current behavior) + ensure cursor forward (current behavior?)X
= ensure cursor reverse, add line aboveAlt-x
= add one line above and below, do not alter selection directionNORMAL (not at bounds)
Same as SELECTION
SELECTION
x
= extend to line bounds, ensure cursor forwardX
= extend to line bounds, ensure cursor reverseAlt-x
= extend to line bounds, do not alter selection directionConsiderations
x
and friends never add new lines in SELECTION in this version.This is less consistent with how other movements and SELECTION mode interact, but keeps almost the exact current behavior of
x
to avoid rocking the boat.The text was updated successfully, but these errors were encountered: