News for hackers. Stuff that matters.
Re:Amp: Vi-like terminal editor written in Rust by atoav on Monday April 12, 2021 @11:42AM (#26780665)
Afaik what the world really needs is a vim like editor with sane defaults, partly overhauled shortcuts that are closer to other tools and some common scenarios solved in less steps (e.g. exiting the editor, multicursor stuff, ...)
Re:Amp: Vi-like terminal editor written in Rust by HKH2 on Monday April 12, 2021 @01:25PM (#26782279)
Kakoune is aimed at multicursor stuff and has relatively sane defaults. It shows help dialogues when pressing key combos too.
Re:Amp: Vi-like terminal editor written in Rust by rapind on Monday April 12, 2021 @04:41PM (#26784881)
Genuinely curious why multicursor is a big deal?
Re:Amp: Vi-like terminal editor written in Rust by joelellis on Monday April 12, 2021 @04:56PM (#26785071)
Multi-cursor editing is the fastest way to accurately modify large amounts of text, especially repetitive text. It's well worth learning for your respective editor. Most other editing methods don't come close, especially in terms of speed.
Re:Amp: Vi-like terminal editor written in Rust by rapind on Monday April 12, 2021 @07:10PM (#26786303)
But it’s still just search and replace right, like renaming a variable or function, or am I missing something?
Re:Amp: Vi-like terminal editor written in Rust by atoav on Saturday April 17, 2021 @05:03AM (#26842746)
What you are missing, is that you get cursors that you can manipulate. Overwriting what they selected is the obvious thing (and then it would be indeed the same as search and replace) — but there are some less obvious things that make this thing powerful in a different way E.g.:

  1. select the next 3 occurances of "foo"
  
  2. Press End on keyboard to jump to end of line (even if the part after "foo" was different each time)
  
  3. Start typing away

You can also use the arrow keys to move the cursors, hold shift to do selections, alt + arrow to jump to the next/previous word and so on. Of course all of this can be done with regexes as well, but it takes longer usually to come up with just the right one, even if you are good with them.
Re:Amp: Vi-like terminal editor written in Rust by sullyj3 on Tuesday April 13, 2021 @12:04AM (#26788024)
The difference is the interactivity and instantaneous feedback. I don't want to have to blindly write a regex substitution when I could instead be seeing what is happening at each step, right in front of me.
Re:Amp: Vi-like terminal editor written in Rust by sagarm on Tuesday April 13, 2021 @02:55AM (#26788925)
Neovim gives you a preview of the result of your regex replacement, and with the ability to reference capture groups it's a pretty powerful.
Re:Amp: Vi-like terminal editor written in Rust by sullyj3 on Tuesday April 13, 2021 @04:31AM (#26789606)
Yeah, I'm a neovim user, and I enjoy that feature. There are just times when multiple cursors would be ever so slightly more ergonomic.
Re:Amp: Vi-like terminal editor written in Rust by majewsky on Tuesday April 13, 2021 @07:58AM (#26791010)
Vim also has it with `:set hlsearch incsearch`.
Re:Amp: Vi-like terminal editor written in Rust by sagarm on Tuesday April 13, 2021 @11:10PM (#26802522)
That doesn't preview the result of the regex, just the text that would be replaced IIRC.
Re:Amp: Vi-like terminal editor written in Rust by hibbelig on Wednesday April 14, 2021 @11:37AM (#26808575)
> Genuinely curious why multicursor is a big deal?

It is easy to see what is going to happen. Also, you can do things that aren't possible (or very hard) with regexes.

Example: You want to add an argument at the beginning and at the end of a sequence of `foo(...)` invocations. You hit the "mark current word" key, now the first "foo" is highlighted. You hit the "mark next occurrence" key a couple of times. Now you have, say, five "foo" that are highlighted.

Now you hit cursor-right and you can immediately see the five cursors move after the opening parenthesis. You type, say "1, " and you see that argument being added to the beginning of the parameter list.

Now for something that isn't easy to do with regexes: You move the cursors to the left until they are all on the opening parenthesis. Now you hit the "jump to matching parenthesis" key. Now you have five cursors on the closing parenthesis. You move them to the left and add your argument.

Each individual editing step is immediately visible. You didn't have to invest the time to come up with a regex that does the trick. But you were able to avoid doing something five times.

Re:Amp: Vi-like terminal editor written in Rust by rapind on Wednesday April 14, 2021 @12:03PM (#26808964)
Interesting. I can see that being useful when editing a json data for example. Not something I run into too often and I can manage the same outcome in vim easily enough, but it’s a bit more advanced so I can see the appeal for sure.
Re:Amp: Vi-like terminal editor written in Rust by atoav on Saturday April 17, 2021 @04:58AM (#26842720)
I am somebody who really has no problem with regexes, but multicursor is something I constantly use in a similar way as described above. This is great for all kind of structured data as well because you can also opt in to only work on certain occurances and immidiately see where things go wrong. When I would so the same with regexes I might use "replace next occurance" but halfway get to one line that fails, undo the lines before, retry again etc.

Once you get the hang of it it is really a quite valuable tool, which gladly you can find in more and more places (e.g. the inspect stylesheet editor in firefox also has multicursors).

I showed multicursors in atom to a greybeard when we were editing some yaml for a ansible configuration and he was really impressed with the ways you can use this feature for that stuff.

Re:Amp: Vi-like terminal editor written in Rust by spartanatreyu on Monday April 12, 2021 @05:05PM (#26785183)
I use vscode and used sublime text before it.

If multicursor was to ever break in vscode, I would switch back to sublime text in a heartbeat.

Multiple cursors is the dealbreaker feature for any editor I use.

Everything else is just too painful.

Re:Amp: Vi-like terminal editor written in Rust by habitue on Monday April 12, 2021 @05:17PM (#26785322)
kakoune integrates multiple cursors as a first class concept, rather than bolting it on. So editing commands that work on "the current selection" transparently work for multiple selections as well. You can see the changes live, which is nice.

For example, global search and replace is the same commands as search and replace, except you select the entire buffer first so that the search will make one selection per regex hit in the file

Re:Amp: Vi-like terminal editor written in Rust by timothylaurent on Monday April 12, 2021 @03:48PM (#26784245)
I've been using https://spacevim.org/ for this purpose for some time, though Vim per-se isn't my daily editor -- I use PyCharm with VIM emulation.

It lazy loads everything and supports most languages, has help throughout, and a responsive community for any issue you may encounter.

Re:Amp: Vi-like terminal editor written in Rust by Jtsummers on Monday April 12, 2021 @11:49AM (#26780774)
What would you do to shorten exiting vim?

  <esc> :wq
Is the longest it's ever been for me and

  :q
Is the norm if I'm in visual mode and haven't edited the buffer.
Re:Amp: Vi-like terminal editor written in Rust by ckw on Monday April 12, 2021 @05:03PM (#26785159)
Space is my leader key, save is mapped to <leader>w, exit is mapped to <leader>q, and <esc> is mapped to jk. So nominally exiting from insert mode in an unsaved buffer (jk<space>w<space>q) is the same number of key presses as <esc><shift>;wq<return>, but in practice, in my opinion, jk is superior to <esc>, <space>w is superior to <shift>;w<return>, <space>q is superior to <shift>;q<return>, and <space>w<space>q is superior to <shift>;wq<return>.
Re:Amp: Vi-like terminal editor written in Rust by hojjat12000 on Monday April 12, 2021 @12:02PM (#26780979)
I think most people don't know that instead of :wq or :q! they can just ZZ and ZQ
Re:Amp: Vi-like terminal editor written in Rust by cassepipe on Monday April 12, 2021 @12:36PM (#26781509)
or just :x
Re:Amp: Vi-like terminal editor written in Rust by ogre_codes on Monday April 12, 2021 @11:54AM (#26780849)
While I agree with most of this...

Who has trouble with ":x"? It's no more keystrokes than any other editor uses. I guess if you are in insert mode it's `esc :x`. I suppose you could bind a single keystroke in normal mode, but it's not that big a deal.

Multicursor would be fantastic. Macro goes pretty far to supporting what you do with multi cursor but falls a little short.

Re:Amp: Vi-like terminal editor written in Rust by anand-bala on Monday April 12, 2021 @12:31PM (#26781430)
As an ex-Sublime and ex-VSCode user, I realized that macros and Visual Block mode covers all my use cases for multicursor functionality.
Re:Amp: Vi-like terminal editor written in Rust by michaelmrose on Monday April 12, 2021 @02:31PM (#26783205)
y and p are better suited to vim usage than control c v I'm not sure what shortcuts you want similar to other tools.

Leaving vim is easy :x if you want to save your work :q if you don't need to :q! if you want to discard all changes to a file These are 3 different operations with the 2 common cases taking 2 characters.

Ultimately if you just wanted different defaults you could trivially provide it as a plugin to vim.