Hacker News new | ask | show | jobs
by edanm 4819 days ago
For everyone here writing that they don't see a need for this because vim has macros/regexp's:

Please, please, try it out. I'm telling you, this is leaps and bounds above macros/regexp's for most use cases. It's the difference between a visual way to make changes, and a "disconnected" way in which you write commands and hope they work.

Seriously, I consider Multiple Cursors one of the greatest advances in text editing, and everyone who doesn't even bother to try it is just being silly.

3 comments

> It's the difference between a visual way to make changes, and a "disconnected" way in which you write commands and hope they work.

Exactly, it's like ed vs vi.

I've been trying it, and do find it nice for small things, but a bit tedious for bigger things. Taking one of the examples in the animated GIF on the linked page, if you want to split a line on commas, with multiple cursors you have to select every single comma to 'initialize' the cursors. If the line has 3 fields, this is easier than using the regex, but if it has 10, then I find it a lot easier to just regex-split rather than spawning 10 cursors. I think I find 3 or 4 cursors nice, but past that prefer batch-style commands to manually managing a big set of cursors.
> with multiple cursors you have to select every single comma to 'initialize' the cursors.

I hear this. Hopefully, the author will be able to implement what Sublime has: a find all field (which accepts regular expressions), and results in multiple cursors on all the matches.

I do this all the time in Sublime and it's so natural:

Cmd+F, /regex/, opt+Enter, [replace, or commands or whatever]

It's just as fast as your usual find and replace or quick macro, except that you have instant feedback, are able to undo, jump around by word, or (with vim-mode), use t or f to find a character, ci", etc.

Selecting a match one case at a time is great, though, when you need to skip some matches. Say you have `old_var`, `old_var2`, and `old_var3`. Just start at the top of the function, and match, match, skip, match, skip, [type and replace]. Sure, you could do a regex on old_var[^\d], but depending on what you're matching and what you're skipping it sometimes is just not worth puzzling out the right regex.

I've been playing with it a bit and I've been seeing the same thing. I do like that this gives me a little flexibility, so I'll probably continue to use multiple cursors for the smaller stuff and the more traditional vim methods for anything larger.
losvedir is right, in ST, "Find" will automatically create separate cursors and takes regex's.

I used to also have plugin for ST1, which allowed you to do common things like selecting a line, then splitting it by a separator. For example, you'd select a line, split it by ", ", and get a cursor on each paramater. It worked wonderfully for these kinds of things.

Yep, the only reason why I wrote this was because of the missing live feedback functionality in existing Vim features, and it's the one feature that the plugin can't do without. I'm certainly not advocating that this be a replacement for regexp or macros, but for certain small tasks like quickly renaming a variable inside a function, it's much easier on my brain.