For now, I'll try explaining: the way I think of it is, it lets you do the exact same thing as macros, except live. Macros in vim/emacs/others are often touted as a great feature, and they are. In vim for example, formatting a huge column of, say, html text involves formatting one row using the proper keyboard commands, then repeating the action multiple times. But with multiple selection, you can operate on all the rows at once, easily seeing what it is you're doing and how it's affecting all the rows.
Maybe even more importantly, it makes it much easier to do activities you wouldn't dream of doing in a macro, since it's much easier and more light-weight. For example, say I have two very similar if statements, one which deals with case "x" and one with case "y". Say I wanted to add a small piece of code to both. I can, with one command, select both "if"s, then just write away that piece of code. Lets say each "if" has a different variable name, I can actually move the cursor up to the variable name, select the name, then paste it every time I need to use it. This is the kind of repetitive task that happens a lot in real-life code, but which you would never use a macro for since it takes to long to make work. With multiple cursors, it works easily.
Summary: multiple cursors make macro-like things 20 times more intuitive and much easier in practice, meaning you use them more, meaning you do less repetitive stuff.
Hope that helps explain it; for more details, you'll have to wait/check out Sublime yourself.
qa
<do what you said>
q
<relocate the cursor>
@a
It's not clear to me at all why I wouldn't dream of doing that in a macro, or how that's not light-weight. Can you explain a bit more what the perceived problem of using macros for this it?I used vim for a solid few months (not that much, I know) and emacs for a while before that. I used both to create macros, but I found one problem: I almost never managed to make the macro work exactly right the first time. This is probably something that gets better with practice, but every time I set out to create a macro, it took some thought into making sure I always remember to start at the beginning of the line, always use searches to find the next piece, etc.
None of this is a reason not to use macros: they still save time when dealing with a lot of text. But this overhead, both the debugging overhead and the "mental" overhead of thinking all these details through, definitely stopped me from using them for macros I'd only use once.
On the other hand, in Sublime, let's say I have two similar "if"s. I select the first "if", hit "ctrl+d" and it selects the second "if", and then I can just start editing. I move the cursor down, move it to the place I want to edit, edit away, all the while not having to think explicitly about this, since I can see everything that happens as it's happening. This is just much more intuitive, and not just for me: other programmers who don't have the same "love of editors" I have watch me do this, and actually ask how to do it too. These are people who wouldn't ever think of using a macro.
I hope that explains why I much prefer it. I really think this is the biggest "revolution" in text editing that's happened in the last few years, and I really recommend you at least try it a bit. I promise I'll blog about this on www.loopycode.com sometime soon, with actual screencasts and some better examples.
it took some thought into making sure I always remember to start at the beginning of the line, always use searches to find the next piece, etc.
Does sublime's multi-cursor support move the cursors around differently? If the next piece isn't positioned the same in the two hunks you're editing, don't you have to use searches to find it with multi-cursors too, or are you suggesting that Sublime has a way of knowing what you're wanting to edit, and moves the cursor around for you?Mostly, this isn't a problem - you can move around using ctrl+arrow keys, which moves by words. Most repetitive code is usually close enough that this solves most problems, though once in a while you'll need to think of some "creative" things to do. These are usually easy, like hitting home, and because you see everything, you can easily see when you need to do it, and what you need to do.
Having said that, there are still some things missing from Sublime Text. I think this whole multi-cursor thing is brilliant and the future of text editing, but we still have to discover a lot of the tricks.
For example, Sublime has nothing like vim's "forward to char" command. This is an absolute must when using multi-cursors, since there are times when moving by words isn't enough. I had to implement this myself (very easy to extend Sublime), since it's extremely useful.
Also, I implemented a few new ways of making multiple selections. For example, I implemented a small function that splits up a selection by a char. So, I can select the inside of a function's variable list (e.g. for "foo(int a, char b)", I'd select the inside of the parans). Then, I use my function and split by the ",", which effectively gives me two selections, one covering "int a", and the other covering "char b". I can then cut these, go to a new line, and paste these on two lines. In this way, I can take a function with 6 variables and easily manipulate each of them, for example assigning them to "this.m_a", etc. This is possible because of a function I implemented for myself, and shows the kind of power I think this kind of editing will have the more people get exposed to it.
got it running on my linux (with wine)
pretty slick... and yes, as a long time vim user, I think the feature will be very useful. although I don't think it's a macro replacement, macro still better for some use case. vim has visual block selection that can do similar thing, but not as powerful as this multicursor thing.
With a multicursor editor, you just drag the mouse over that area to put a cursor on all those lines, and then type the fixed version to apply to all at once.
Regexes would do just as well, but depending on how comfortable you are with them this is a bit more rapid.
Across a whole document I just don't trust it to do what I am expecting when I can't see all the changes on the screen at once. Search and replace remains a much more intuitive (to me) approach.
I've often seen reluctance to actually put in time to learn powerful tools. I plan to be programming and working as a sysadmin for many years to come, and it's obvious to me that the sooner I learn to use more-powerful tools, the greater the benefit is to me over the rest of my programming career. You can get the basics of regular expressions down in an hour or so, and progressively learn more as you encounter it, and that benefit will pay off repeatedly, and yet I've seen many people refusing to learn things like that.
Anyone have any insight into this?
Second, most new tools are not worth learning. More importantly, learning all the tools that make you better is definitely a wrong move. So people are naturally reluctant: they figure if it's really important, they'll learn it eventually when they run into it again (like the proverbial sysadmin who doesn't do anything unless he's asked to do it 4 times).