5 ms·
Rectangle editing commands in Emacs take care of 99% of the applications of multiple cursors. I have never had a use for them.
by davexunit 9y ago
Rectangle editing commands in Emacs take care of 99% of the applications of multiple cursors. I have never had a use for them.
- yoodenvranx 9y agoRectangle editing does not cover 99% of my use cases for multiple cursors in Sublime Text.
- Veedrac 9y agoRectangle edits are equivalent to a tiny minority of what I use multiple cursors for (and are generally just rare overall), so this doesn't make much sense to me.
- mcherm 9y ago> Rectangle edits are equivalent to a tiny minority of what I use multiple cursors for Okay, now THAT is interesting. Can you comment on some of the other uses you have for multiple cursors? Perhaps give some examples?
- junke 9y agoFor all the things that are not aligned vertically in strictly consecutive lines. Suppose you wrote some silly code like this: (cond ((eq x :one) ...) ((eq x :two) ...) ((eq x :three) ...)) Replace "cond" by "case x". Select first "eq x", mark the other two (you have 3 cursors now), forward to the keywoard, M-<up> (with paredit): (case x (:one ...) (:two ...) (:three ...))
- Veedrac 9y agoAs an example, at the moment I'm juggling a large number of constants where I'm still learning how to classify and group them. I can use alt-d and alt-shift-d to select between local groups, either whole words or just suffixes, and rename them locally. A multiselection is normally, say, 3 to 10 selections of 3 to 10 characters, so the edits themselves are far too tiny and frequent for macros to meaningfully help, yet far too irregular for column selection to help. At the same time, multiple selections are acting as an incremental search and a way to jump between places. Frequently I do want to do regular operations, but columns are way too restrictive. Say I had something like the anonymized code Salad foo; foo.fred = chance(mulch, 4, 1); foo.fools = chance(mulch, 7, 4); foo.cheese = chance(mulch, 10, 7); Salad bar; bar.run = chance(mulch, 4, 1); bar.jump = chance(mulch, 7, 4); bar.fly = chance(mulch, 12, 7); Salad crouton; crouton.crunch = chance(mulch, 4, 1); crouton.splat = chance(mulch, 7, 4); crouton.swim = chance(mulch, 12, 7); and I wanted to subtract one from the middle argument to each call to `chance`. Column selections aren't impossible here, because there is some structure, but with multiple cursors I can just select all the relevant `chance`, ctrl-right to the end of the relevant number, write "-1", ctrl-shift-left so I select the expression, and press my evaluate key (ctrl-shift-e) to run the subtraction. Or say I have some Markdown and I want to give a correct-width underline to a title. ctrl-d to duplicate and select the new line, shift-left to unselect the newline character, alt-c to break the selection into characters, and then just press "=" to replace them all. Or say I want to reformat a function call so all the arguments are on new lines, I will naturally gravitate to selecting a separator (the comma in all likelihood) and just adding a newline there. I can keep some arguments together by just skipping those. This isn't to say multiple selections is the only way to do this stuff; this is just the way I like doing it with my editor.
- NoodleIncident 9y agoThe "all hat and no cattle" link in the OP is a much better argument for macros>multiple cursors: https://medium.com/@schtoeffel/you-don-t-need-more-than-one-cursor-in-vim-2c44117d51db https://medium.com/@schtoeffel/you-don-t-need-more-than-one-... Editors without vim macros probably need multiple cursors, but the main argument in favor of macros is that (for things like the markdown underline macro), it's easy to save it for later, and you can see it happen to every location even if some are offscreen.
- sullyj3 9y agoThe main argument for multiple cursors over macros is that they give a tighter feedback loop. If the macro you record works for the section where you recorded it, but doesn't generalise, without thinking hard about it (undesirable) you won't know about it until you actually go and run the macro in an incompatible spot. Once that happens, you either have to re-record it, or dump it out and edit it manually. Neither of those options can be said to be particular friction free. By contrast, with multiple cursors, if you do something wrong (or right in some places, wrong in others) you know about it immediately, and you can fix it immediately in a friction free manner. I don't think multiple cursors can replace macros in all situations, but it needs to be acknowledged that different tools have different strengths and weaknesses, and when choosing which to use in a given situation you should keep that in mind. Dismissing one because the other is more powerful is like always using a sledgehammer to knock in your nails. Sometimes the other is more convenient, or more user friendly, or less of a pain in the arse in some other relevant way.
- shalabhc 9y agoThank you for taking the time to explain. I don't use multiple cursors but now see how it might be more accessible than using regex based replace commands or macros. The key point I got was one already knows how to edit with one cursor and multiple cursors extends the same behavior trivially. Anything else (e.g. macros) first requires learning a completely new model and behavior.