Hacker News new | ask | show | jobs
by marklgr 1655 days ago
Multiple-cursor editing is a nice and cool feature, and for what it's worth there are some vim plugins to get it in vim, but let's see the alternative:

- multiple-cursor: select non-contiguous pieces of text, then edit them all at once.

- vim macro/repeat: edit a piece of text, and repeat on similar occurrences.

The vim "way" could be, `/;$` to select the trailing semi-colon, then `cgn` to edit it (enter the curly block once in insert mode, then exit with `<Esc>`), and now you can repeat on the next trailing semi-colon simply by hitting `.` (dot).

So, instead of first looping on the occurrences to get multiple cursors, then do the editing, you first do the editing on an occurrence, and you loop on the editing. There is admittedly less of a "wow" factor, but I don't think it is any less powerful.

(edited for formatting).

1 comments

It is way harder to use macros than to do multiple-cursor editing, especially for the kind of fast changes that happen 10 times a day. The difference is between seeing interactively exactly what you are doing and where something is going wrong (with multiple cursors), vs. recording a macro, replaying it, realizing you forgot to do something like use the correct keybinding, rerecording, etc.

I say this as a huge vim advocate, who used vim exclusively for 8 years before switching to emacs and lately to vscode.

Vim gets a lot of things right, and there's no comparison to using vim-style editing. But multiple-cursor editing is a killer feature that really does improve your workflow a lot of the time. Luckily most editors have some version of it now, though often not as good as the original and doesn't always play nicely with the various vim modes.

If you insist, you may have a look at https://github.com/mg979/vim-visual-multi

It implements multi cursors in vim and combines it with vim movements etc.

Yeah I used it (or something similar) when I was actively using vim. It wasn't as good as a proper IDE but was fairly good for a variety of use cases.

(I actually tried to implement my own multi-cursor plugin in vim, and got a decent amount of the way there before realizing my fundamental approach probably wouldn't work.)

Maybe because I’m also a maker I don’t expect my tools to do everything… what’s wrong with using vim for what it does very well, and then Sublime (geany, kate) when a gui is just easier?
Nothing at all!

But the way I use my editor is that I'm usually in it all day. Both for editing code, but also for personal notes, etc. So it's on all day and I spend most of my time in it.

This effectively means I have one tool that I mainline. I'll still use vim in the odd situation where I can't use my main editor, but it's usually just easier for me to open files in the editor I already have open.