3 ms·
> Genuinely curious why multicursor is a big deal? It is easy to see what is going to happen. Also, you can do things that aren't possible (or very hard) with
by hibbelig 6y ago
> Genuinely curious why multicursor is a big deal?
It is easy to see what is going to happen. Also, you can do things that aren't possible (or very hard) with regexes.
Example: You want to add an argument at the beginning and at the end of a sequence of `foo(...)` invocations. You hit the "mark current word" key, now the first "foo" is highlighted. You hit the "mark next occurrence" key a couple of times. Now you have, say, five "foo" that are highlighted.
Now you hit cursor-right and you can immediately see the five cursors move after the opening parenthesis. You type, say "1, " and you see that argument being added to the beginning of the parameter list.
Now for something that isn't easy to do with regexes: You move the cursors to the left until they are all on the opening parenthesis. Now you hit the "jump to matching parenthesis" key. Now you have five cursors on the closing parenthesis. You move them to the left and add your argument.
Each individual editing step is immediately visible. You didn't have to invest the time to come up with a regex that does the trick. But you were able to avoid doing something five times.
- rapind 6y agoInteresting. I can see that being useful when editing a json data for example. Not something I run into too often and I can manage the same outcome in vim easily enough, but it’s a bit more advanced so I can see the appeal for sure.
- atoav 6y agoI am somebody who really has no problem with regexes, but multicursor is something I constantly use in a similar way as described above. This is great for all kind of structured data as well because you can also opt in to only work on certain occurances and immidiately see where things go wrong. When I would so the same with regexes I might use "replace next occurance" but halfway get to one line that fails, undo the lines before, retry again etc. Once you get the hang of it it is really a quite valuable tool, which gladly you can find in more and more places (e.g. the inspect stylesheet editor in firefox also has multicursors). I showed multicursors in atom to a greybeard when we were editing some yaml for a ansible configuration and he was really impressed with the ways you can use this feature for that stuff.