-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
commandline --selection-anchor
to get/set selection start position
#9197
Comments
Typically, to change the selection, you would just use one of the bind functions that changes the selection. E.g. you'd press right-arrow or ctrl+b or h or something, or trigger the corresponding bind function via So, the question is: Why do you want this? What is the idea that you need this for? |
I'm working on this: https://github.com/sshilovsky/fish-helix (helix-like bindings, helix is a modal editor similar to kakoune (#7748)) I'm trying to reproduce helix behavior as precise as possible, and for some motions this would be very helpful. And some seem to be impossible to implement with existing commands (e.g. Alt-: to ensure that the cursor is on the right end of the selection). |
Okay, so you want fine-grained control over the selection, and your idea is that you have two ends, the cursor and the "anchor". Moving the cursor moves the one end, and moving the "anchor" moves the other. I would call it the "selection-start". It might also be useful to accept relative movement as well - something to express "move the start one to the left" or right, without having to first query for the position. This would of course also be useful for the cursor position - it would remove a bunch of your math calls. E.g. instead of commandline -C (math max\(0, (commandline -C) - $count\)) just do commandline -C -1 |
Relative movement would be a nice addition, but it's not the most urgent thing to be honest. Imho I agree on |
For example, with the buffer
abcdef
and selectionbcd
, with cursor on the right end:commandline --selection-anchor
should output1
;commandline --selection-anchor 2
should switch selection tocd
,commandline --selection-anchor 3 --cursor 2
should selectcd
, but also swap the beginning and end of selection to backwards.UPD fixed: --selection-anchor 3 in the last line example
The text was updated successfully, but these errors were encountered: