well, just the fact that multiple selections are possible means there is another level of complexity to deal with compared to Vim
. Even just needing to remember which keys to use to swap selection cursor/anchor, or rotate selections, is all extra information to keep in your head while you’re learning this. So, especially when I’m goal-oriented, I can’t see the forest for the trees. Thanks for the overview – that’s helpful.
Note that there are two different kinds of ‘complexity’ occuring here; one of learning the interface and one of using the interface. Once you grok the multi-cursor operations available, I would consider the level of complexity in “use” of the editor to be substantially lower to that of the various approaches offered by vim.
To search and replace a piece of text in vim you must understand and utilize a s// regex or macro your replacement and then . until it breaks. With multiple cursors, this is accomplished with the basic editing primitives (assuming you treat multi-cursors as a primitive) with no regex or error-prone manual iteration required (though you still can). In Kakoune it is just “select-all > filter > change”.
Multi-cursor operations can certainly seem confusing at first, but I sadly think this is just due to the fragmentation of the default keymap for these related actions. Perhaps instead view it this way; there are only 3 things we can do with multi-cursors:
1. Create cursor
2. Delete cursor
3. Rotate through active cursors
In my Geospatial mapping, these operations are simply mapped to standard keys.
c = create cursor
z = delete cursors
x = rotate active cursor
If we take advantage of the really useful ‘selection undo/redo’ feature that is buried in Alt-u which I have put on a dedicated key as well, you have a fully error-prone multi-selection approach that only requires 4 keys. Swapping anchors is not a multi-cursor-specific operation, but it seems to only really be noticed/used when using multiple cursors.
So in regards to your confusion about multi-selections (with my Geospatial mapping) “extracting yourself from multi-cursors” is just pressing z. “Turning selection direction around” is just pressing ;. Your primary cursor should be colored differently in your colorscheme so you always know where you are; then rotating between active cursors is just pressing x.
Eak leans more towards working with “objects” than my Geospatial map which is more about direct cursor interaction, but they both benefit equally from multi-cursors. This is how I would solve the table problem assuming my cursor resides on the first | in the table
CgdaaavmY,<ret>
and then pipe. In plain english, I use C to make cursors for all matching vertical |s, move cursors to the end of the line, move cursors into (), select it’s contents, and then split. Whenever I am done with multiple cursors I clear them with z just as instinctually as I use <esc> to clear a selection I am done with.
I am so quick and proficient at text-editing I have to stop myself from just duplicating code rather than refactoring because it’s so easy for me to do it, and the only reason I can say this is because working with multi-cursors is that powerful.
Not recommending you utilize my mapping as it’s different from Eak, but I hope the explanation of why I have designed it that way will help clarify multi-cursor operations. I use multiple selections for everything that would otherwise involve repetition and it now makes the use of macros and other vim approaches seem clunky and too error-prone.
I have simplified the (embarrassing) awk code in the original post along the lines of your comment.
Aside from simplifying the arithmetic, thanks for pointing out that the original challenge can be solved by piping a single line block to awk
I still think that piping multiple selections to awk is easier than your solution (which requires counting fields and splitting field 4 in subcomponents that need further counting).
The following challenge would have been a better fit to illustrate the value of multiple-selection piping:
| Foreground | (156,52,31) |
| Background | (0,76,115) |
| Main Color | (128,86,25) |
| Accent Color 1 | (34,51,85) |
| Accent Color 2 | (22,51,85) |
Of course you can still do it with a single selection piped to awk, but barriers crop up ![]()
NB: yes, awk is fantastic. I do not think anything beats (g)awk for data munging/wrangling, which is 90% of what data analysis is all about…
Ok – I understand your point now. And you are right: the mere fact that multiple selections exist add complexity to the editing model. However, you must distinguish the complexity of initial learning and complexity of usage. On this score, I fully agree with @mutt’s reply.
Thanks @mutt, you articulate very well what I’m trying to get at. I definitely intend to explore Geospatial next. Just one thing at a time
. Thanks also for your high-level breakdown of working with multi-cursors. This is the most valuable kind of documentation, at least in my mind.
I believe it! Unfortunately, one Christmas holiday was not enough to get up and running, but I will keep at it.
gawk -F\| '{split($3,arr,"[(,)]");print $0" (" arr[2]*257 "," arr[3]*257 "," arr[4]*257 ") |"}'
I would also use multiple selections if I only had to do it once, but often once turns into many times. I have gotten stuck using multiple selections where an awk program was the better solution. Both are wonderful features of kakoune.
.p,s. full instructions are pipe | the selection to the awk command and append - to tell awk to read from the pipe
I should have written:
![]()
I see your point, though. What you lose in terms of ease of writing, you gain in repeatability. But then, another way to achieve repeatability would be to wrap all of the multiple-selection stuff (including the pipe instruction) in a macro.
I do not use macros a lot, but sometimes they are handy ![]()
I’ve got 10 years experience and I’m still learning! It genuinely is like learning to play an instrument, including the practice time necessary.
I wouldn’t consider Geospatial fully perfected, but it’s certainly helpful for understanding the operations available in kak to make sense of your own layout. I still need to fully explore Eak, there’s certainly things I can learn from it’s design.