Swap `d` and `r` for better vim compatibility
dd deletes the current line, but the line is not on the clipboard, so you can't paste it using p.
This is by design (see README). Granted the design is debatable, but that's a much larger discussion. Use rr for deleting and yanking simultaneously (like Vim's dd).
Thanks for explaining. But yes, I think it should adhere to vim's behaviour as closely as possible.
@jpotterm I'm curious as to the reasoning behind this. This and the lack of ">" are the only things where I'm pretty sure they are now so hard-wired into my brain that using simple-vim would become a step back in productivity that is greater than what would be gained by having the default multiple cursors working well. Any chance you could add an option for dd to do rr instead?
@gerrywastaken Sorry about that. I'm happy to explain the reasoning behind it, but I'm not going to add a configuration option for that. If you can't tell by the many deviations from regular vim, simple-vim was never meant to be as close as possible to that experience. I wrote it mostly as an experiment and for my personal use. The experiment was to see how little code (and effort) I could use and still have a vim extension that was useful. So hopefully 20% of the effort for 80% of the usefulness. To achieve that goal I decided to try as much as possible not to duplicate native VSCode functionality in simple-vim. > is a good example of this; Cmd+] does exactly the same thing so there's no need for simple-vim to do it.
Another feature that I cut to try to make things as simple as possible was named registers. Named registers can be useful, but personally I use the default register most of the time. The main reason I use named registers in vim is to prevent dd from overwriting what I yank. And (also my personal experience) 80% of the time when I use dd I don't want it to yank. So the solution to all of those things was to make dd not yank by default and to add another command, rr, if you do want to yank. That allows removing the entire named registers feature and saving a lot of code. It also makes it much easier for newbies to learn because they don't have to worry about named registers or accidentally overwriting the things they yank.
So anyway that's the reasoning behind it. I realize there are a lot of decisions simple-vim makes that can be annoying for long time vim users, and I'm sorry about that. If you want all of your muscle memory to work without changes, I recommend you use an extension that prioritizes that (like VSCodeVim). That's definitely not a priority for simple-vim. But this extension is open source so if someone wants to fork and make something like simple-vim that prioritizes compatibility with vim I'm sure people would find that useful. Or if VSCodeVim wants to take the multi-cursor ideas from simple-vim and use them, that would be great (although I think it would be a huge architectural change for them).
I absolutely agree with your decision to skip implementing registers. However, it would make my life a lot easier if you added an option to swap d and r. I absolutely understand why you want a delete that doesn't overwrite the register and I absolutely support the idea of having that, but changing the behavior of d is not the right way to go IMHO. Also for your 'easier for newbs' argument. I'd argue that nobody new to vim will come to learn vim on VSCode, and especially not with something other than the most popular vim extension. And even if they would you're teaching them vim wrong.
80% of the time I want dd to also yank. And the brain-rewiring is hard, and all other editors where I use vim controls behave differently. So please, please reconsider adding an option for this. Also, I don't know TypeScript yet, but would you accept a PR if I were to implement the option?
Good points. I agree that the "easier for newbs" argument is a weak one and you're probably right that the vast majority of people using this extension will already know vim.
I guess the real reason is that I feel like 80% of the time I use dd I don't need/want it to yank. Maybe our usage is different, or maybe one of us is wrong about the percentage. Regardless, swapping d and r would give better vim compatibility for not much down side, so I'll seriously consider it. I'm reopening this so I don't forget about it.
Don't worry about submitting a PR. It's ridiculously easy to implement. The philosophy is the only thing I'm considering.
Thank you for making this extension! Unfortunately, I couldn't get over the muscle memory difference between dd and rr since 100% of the time I follow up with p on the thing I just deleted, so I added this to my own local copy.
I really appreciate your thoughtful response and the reasoning. Even if you don't end up making the change I really appreciate that response. :)
Can you merge in Joey's (jl) changes to support 'dd' and 'p' as it is suppose to be handled?
I'd also like dd to yank, but who am I to complain here ;). I came from the vim extension in vscode that was horrible at multi-line, so I am happy simple vim works for this. How hard would it be to allow us to set all the commands to different keys through the keybindings settings in vscode?
@abuisman I'm glad you like the multi-line support! I worked really hard on that. I originally looked in to using VSCode keybindings for configurability, but I don't think they will work. They could probably do dd but there are all of the operators based on d that we'd also need like dap and they're not powerful enough to do that. For one thing I think they only support chords of length 2. For another, it would be a ton of keybindings because it would be number-of-operators times number-of-motions. I did use VSCode keybindings for Ctrl commands which they work well for, like Ctrl+d, so those are configurable.