Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And I consider multiple selections a flaw, a poor man's search&replace. Particularly with neovim's

set inccommand=split

(live substitution). Vim's confirmation prompts make it more comfortable, as well as off-screen matches it shows. Multiple selections are inherently limited to a single screen or you won't be able to see what you're doing.

Verdict: a gimmick.



Kakoune goes the opposite way, there is no such thing as "search and replace" in it, you'd use multiselection for that.

It ends up being much more powerful because the editing language is strictly more expressive than regular expressions: you can select using a regular expression, but you can also use all the rest of the normal mode, such as select/jump to the matching parenthesis or brace (or whatever pair of text your language use to scope things), which is not possible to express in pure regex.

You are far from limited to a single screen, the `(` and `)` commands rotate the main selection, so you can inspect all your selections easily if you want to.

In my experience (as a long time Vim user and as Kakoune's main author) multiple selections end-up being much more attractive for quick edits where there's only a handful instances to replace than devising the correct regex/replacement pair, and their interactive nature makes them quicker to use than the macro alternative (which is also supported in Kakoune).


I'd just like to add that if you want to do regex-based search and replace like in Vim, it's super easy to pipe your selection through sed. The way Kakoune implements pipes is just amazingly good. I love that if you have multiple selections, each one gets piped through the command. I love that you can undo piping your selections to another program. And while I've barely scratched the surface of what you can do with macros, I have a couple that I use constantly. After 19 years with vi and then vim, I switched to kak after trying it for a week.

In summary: great job with Kakoune! I'm a delighted user.


As I've said in a thread I made on forums a while ago, search&replace has other advantages. Reviewing matches, as long as you use /gc, is the default in vim. It's opt-in in kak, which I think is a bad default. Does kakoune even indicate you have some other selections off-screen?

I worked with large and messy codebase, where apparently there was always something more important than cleaning up.


I considered multiple selections a bit of a gimmick in sublime text and various emacs/vim extensions but the way it works in kakoune feels completely different.

Think about vim (and kakoune) as basically a highly interactive language for editing text. At least at a conceptual level something like diw is basically a function (d) applied to data (iw). Vim is completely scalar. The type of all the functions is more or less something like string → string. Kakoune is the APL of text editors. Multiple selections are an array of strings to operate on. It automatically maps the function (editor commands) over every selection. I find this extremely attractive and powerful.

At least for me kakoune blows all other editors out of the water. It really is quite good.


When I tried `set inccommand=split` in neovim it would sometimes freeze the editor, even when substituting regular-sized files (several Kb), so I had to deactivate it. Granted that this was some time ago, so it might have been improved with recent versions.

To me however multiple selections are not Kakoune's strongest point. It's the fact that in Kakoune you "first select, then modify", while in vim you go "action first, then subject".

Putting the subject first allows for a more visual experience in general - in Kakoune you can always "see what's going to happen" before it happens, because the object is always highlighted. The multiple cursors thing is just a manifestation of this approach. In Vim the experience is more "opaque" - you type some commands in normal mode and suddenly the text changes. As a result Kak is less prone to "accidental edits" like I get in Vim from time to time.

I've heard that some people "abuse" on Vim's Visual mode to get over this limitation. But that feels like a kludge to me. And it doesn't solve the accidental edits.


Multi-cursor is actually a better version of search-and-play-macro, not search-and-replace.

The advantage of it is that you can execute the "macro" incrementally and spot early when you've made a mistake, rather than recording a macro then letting rip and discovering, too late, that there was a mistake 80% of the way though, and now you need to undo the whole thing and and try again.

(I use multiple-cursors in Emacs for multiple selections, iedit-mode for live substitution (sometimes in combination with wgrep), as well replace-regexp for plain search & replace, and while they all overlap, none are poor versions of any of the others. They each have their strengths and weaknesses. However it's vanishingly rare that I use macros any more.)




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

Search: