On-the-Go Multicursor Laying #5968
Unanswered
raffimolero
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
MORE FORMAL ALTERNATIVE
man i should read before writing
anyway here's like a really minimal way of implementing this
Let's say I want to extract only the correct words from this sentence:
Using a regex is impractical.
copy_selection_on_next_line
can't be used on one line. Ctrl+click is subject to inaccuracy. Macros can't yank them all at once. You could select every word and remove selections one-by-one, but I'd like to do the inverse.I could use something more fine-grained.
Proposal: Cursor-Laying.
To start with a familiar idea, take
C-s
. It takes all your currently active selections and saves this "jump point" to a jump list, which you can laterjump_back
to withC-o
. In the meantime, you're free to move around. This is almost what I want. I just need to add one more operation at minimum:C-O = "jump_combine"
- works just likeC-o
except it keeps your current selection on top of the jump. (show error if the jump is in a different file.)This change seems simple, but is actually pretty powerful.
C-s
is already able to save multiple selections at once, so we can basically add as many selections as we want to a single jump point.To put this into practice:
The
, then hitC-s
. nowThe
is in my jump list.not very
.quick
.C-O
. now i'm selectingThe
andquick
with 2 cursors. It keeps my primary cursor atquick
.C-s
to save these two cursors into one point in the jump list.,
to go back to moving with one cursor.brown
.C-O
selectsThe
,quick
, on top of my primary cursor atbrown
.C-s
and,
.fox
.<C-O><C-s>,
jumps
.<C-O><C-s>,
lazy
.<C-O><C-s>,
dog
.C-O
,And now, i've selected all the desired words. i can then yank them or change them or append/insert/whatever, in-place.
hopefully you see how powerful this can be.
You may have noticed the repetition. In this state, users might bind
C-j = ["jump_combine", "save_selection", "keep_primary_selection"]
.But because this technique creates so many jumps in the list, we might as well give a builtin
C-j => jump_append
which only appends to the previous jump point instead of creating a new point each time.The jump list caps at 30, so any previous jumps that you might have wanted could possibly just be replaced by like 25 points that just say
"The"
,"The", "quick"
,"The", "quick", "brown"
, etc.Would this be viable? I find myself wanting this every now and then. Decently often.
More advanced techniques could involve juggling between multiple "selection groups" which are just different jump points that were appended to. Not sure how practical that would be, so I don't consider it a priority, but it's an idea.
Beta Was this translation helpful? Give feedback.
All reactions