Hacker News new | past | comments | ask | show | jobs | submit login

I speak vim, but vastly prefer multiple cursors when the editing is less trivial. Say you want to turn

  "foo bar" # For the 1st line
  "baz qux" # For the 2nd line
into

  "bar" # For the foo key
  "qux" # For the baz key
With multi cursors, you could select foo and baz and then interactively edit the rest of the line. I'm capable of doing that with vim, but by the time I'd even settled on an approach for it, I'd already be done in the other editor.

I could use Emacs macros to do the same kind of thing, and I've probably used `C-x (` a zillion times to build procedures I could then run 30 more times on the following lines. For quick interaction, I still prefer multi cursors.




For this specific example it's a visual block select of <foo > / <baz > cut and then visual select of <1st > / <2nd > and paste. But that's relying on things being the right width.

This is two lines, if everything was a different length, I think by the time I got multiple cursors to do this, I would have long managed by just doing the same editing task twice (cut overwrite-paste then cut overwrite-paste).

If I had to do this for many more lines I would have just used a substitution:

    :s/\(.*\)"\(\w\+\) \(\w\+\)" # \(.*\)\(\d\+\w\+\).\*/\1"\3" # \4\2 key/
And yes, that's 100% unreadable, but it was easy to write with the preview mode on modern neovim.

Although in this case I think a macro would probably be what I would settle on. This macro would look like:

    ^wdw/the<ret>wvawpwciwkey<esc>j (<ret> and <esc> are ^M and ^[ but I replaced them to avoid confusion)
But these are already the motions you would need to use to keep the multiple cursors in alignment. The thing is though that if you screw up it's usually easier to unscrew yourself when it's just one line than when you've gone ahead and screwed up 20 times. Yes it's still just an undo but when I've used multiple cursors, especially when you're trying to break up lines, you're forced to deal with that breaking up happening in all cursors. Things quickly get overwhelming.

Multiple cursors are effectively (in my experience) just macro recording with automatic playback simultaneously at all the positions you care about. Whereas if you just record a macro and apply it wherever you would otherwise place your cursors, you get the same result without having the visual mess of dealing with multiple cursors. And it's just as error prone as macros.


For longer distance, I use search navigation, faster than scanning where to put the cursors.


Vim can do multiple cursors as long as they start on the same column: ff<ctrl-v>jdw




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: