Just thinking out loud how to do that in vscode for comparison:
- I don’t think repeating actions a specific number of times makes sense in most use cases. Counting 10 lines would take longer than doing shift up/down n times (which would be exact with feedback) to select the desired lines.
- Multiple Copy Paste buffers sounds interesting, I might look up a vscode extension for that. (Had a copy paste queue in Visual Studio but it would break sometimes and would lose something important).
- go to start of function jnk, there are many ways to do that in vscode. Ctrl+f jnk enter would be one.
- Goto start of document is Ctrl+Home
- Indent 20 lines by 10 spaces, could do Alt+PageDown, then up/down to get to the right place (without counting or caring that it is exactly 20 lines), then with multi-line insertions could space,tab, etc.
That operation would probably justify mouse usage though, in which you simply hold alt, drag ~20 columns/~10 cells and hit space - which itself would be faster than counting 20 lines.
- find junk: ctrl+f junk enter
- select 15 lines (shift+page down,up/down to adjust) I can preview I have selected the correct area, other possibilities to select current function, etc.
- Ctrl+h to replace, a1 tab A1 Alt+L Enter
- of course in most cases, I am renaming a symbol, so “F2 A 1 Enter“ would do
I think the reality is that counts are not known before hand, so being able to increment/decrement with visual feedback is perhaps faster than a miscount, but I’d have to see it to know.
Anyway, thanks for the detailed examples! I can certainly see how it would be powerful if committed to muscle memory, but even with vscode there are many shortcuts I don’t use because of formed habits.
There is never any "counting lines". If I need line's number, I can do a quick addition/substraction in my head or j/k $offset to see the other line's absolute number.
I can do line-based operations a lot faster than shift-tapping or click-dragging, with exact precision because my editor has been customized to provide the data I need. Eventually you get pretty good at estimating line numbers and character columns too.
for line counting - indeed a good point and clearly required for the examples -
After time, eyballing this becomes a skill. For things that fit on a screen (~50 lines or so, give or take) I'm usually correct 1st time or within a few lines. I can check quickly by moving the cursor (20j to go down 20, 20k to go back, repeat if necessary to get the line count)
also as others have pointed out, I might not be doing the best/optimal thing for some of these, just some examples of how I do things that popped in my head :)
Vim get round that by providing the option of relative line numbers to the current line.
That’s accessed via
:set relativenumberNit pick: "q selects register q. A buffer is a different thing.
The real scenario is usually to replace, for example, in a function block. How do you do that? Counting function lines seems like a non-starter.
I believe this is an area where treesitter can help, so I'm looking forward to Neovim's integration.
Of course Vim can replace a function block easily and has been able to do so for decades.
For example, let’s say I have a json object with variety of field names, one per line and I want to remove the quotes.
With vscode, I can alt select all lines, Home Ctrl+right del cntl+right del.
The trick is the field names are different length, does vim have multi-edit with the ability to navigate relative to each insertion point?
Edit: Here is a good video example (https://youtu.be/iomWEDMBlcE)
Can vim do something like that?
If I wanted to cherry pick examples of what vim does better, I could start all of them with, "first ssh into a random server."
What makes vim great is that it has a tremendous number of features and is available nearly everywhere. Can VS Code do that?
If you’re on a new machine, you can grab your dotfile repo from wherever you keep it—like GitHub for example—and you’ve got your complete config, since there just text files. Takes 5 minutes.
But even plain vanilla Vim is more than enough for many tasks on a new Unix/Linux box.
Evil is also the best and most complete vim experience outside of vim.
> Here is a good video example (https://youtu.be/iomWEDMBlcE)
Again, you can do everything here without using multicursors, just record a macro for one line and repeat with a count and you're set.
Now if you absolutely want the multicursor feature, there are more than one plugin[1][2] for that, but I never felt the urge to use multiple cursors in Vim.
0: https://youtu.be/YR7rRC-vwj4
For example you could use the visual block mode (ctrl-v) and highlight to the end of the line using $ and then use A to edit the end of every line at the same time. That works with lines of different length.
Or you could use a regex inside of a block selection.
Or there's a multi-cursor plugin available for the same approach as you're currently using in VSCode:
https://github.com/terryma/vim-multiple-cursors
Vim Golf is an excellent resource for seeing how to efficiently edit things in Vim: https://www.vimgolf.com/
"q10yy /jnk "w5yy 10G "qp "wp "qp
now, go to the start of the document and indent the next 20 lines by 10 spaces:
0G .,+20s:^: :
ok great, now find JUNK and replace 'a1' with 'A1' in the 15 lines that follow:
/JUNK .,+15s/a1/A1/g
probably not as efficient for multi-file refactoring, but for raw 'drag race' style text munging, everything is there, loaded in muscle memory, and under the home row of your keyboard so you don't have to lift your hands at all.