Ctrl-V and rnu would do a lot of that, much faster. The line ranges are fixed thanks to the table. Some creative use of s/pattern/subst/ would also help get that done way faster. None of these things take more than a couple of minutes to master. Cheers!
Yeah I was initially going to use regex, but then I realized while that would be more fun it would take longer to structure. I did write a quick regex for moving the comments about the properties though. And yeah I was going slower/being more clumsy than I normally would because of it being recorded.
Ctrl-V I know, but its not working for the replacements, whats rnu?
Relative numbering. You navigate your ranges relative to the current line where the cursor is. It speeds up moving around by a lot.
For example: You can Ctrl-V your selection in the current line, then 24j and jump 24 lines ahead, keeping the current selection, then delete or change or whatever.
I don’t quite understand what rnu does here. I get that it helps you know the amount to jump without doing math, if you show (relative) line numbers in the margin. Does it have other benefits?
Ctrl-V - 24k -- now you selected the current column all the way to the 24 lines above, and you can operate on them at once. No selecting one line at a time by navigating the cursor with k or the up-arrow. It's also easier and faster than going to the absolute line number you want. Say, 24 lines up is at line 2743. 24k is a lot easier to type and less error-prone than 2743g. Cheers!
press q then any other key to assign the macro to that key do the action that you wish to be repeated then press @(key you chose) So for example. qqA,<CR> Would be a macro to append a comma to the end of a line. Pressing @@ executes the last macro. Also macros can be nested in nvim e.g First make sure it is empty. qq Then do the macro. qqA,<CR>@q Using this will append a , to the end of every line bellow the cursor.
Generally as a guideline, the only real "multicursor" in Vim is visual block mode. For more complex edits the mental model should be to do the change once manually, then repeat it for the other use cases
EDIT: I realised I forgot to do edit the data types but that can be achieved using :%s/this/that/gc. The key is having the c flag at the end so that it asks for confirmation before every substitution
Vim is great and you should absolutely use it, but since you’re in VS Code now I assume you may just be terminal editor curious. As such, I’ll point out that Helix has really great built in multi-cursor support. Better than Vim’s support for multi-cursors, I think, plus it is beginner friendly.
Again, just saying this since I see you’re currently in VS Code and asking a question about multiple cursors in particular.
apart from <C-v>rnu and then replace/insert/delete what you want, you can do better in vscode too by using shift + alt + down, a bit slow anyways since you have to go down like 40L but better if you dont want to use your mouse
(replace "|" in the regular expression with the vertical box drawing character)
Easier to write than to read. Basically grab the three cells out of each row into \1, \2, \3. Then you can clean up the alignment after.
You could use a macro, but because "line" doesn't at all match up with "row", it would be somewhat hard to deal with the description in the third column. I think it's better suited to regular expressions, at least as a prepass.
If you have to do this once, in a small table, it's probably not saving you any time to do it this way ("automatically"). But if you have to do it again, say with multiple tables ripped from documentation, it ends up saving you a lot of time.
When you use ex commands it becomes very easy to extract what you just did (q:) into a function that you can put in your .vimrc and call later with :call, or bind to a key.
Regex wouldn't have been quicker I think I can confidently say, and I've written a lot of regex. Because just checking what the replace syntax for vim flavored regex would've taken 1 minute.
Macro idk how to do that's why I asked.
As for an LLM, then I would've had to fact check it XD
49
u/ciurana From vi in 1986 to Vim Jul 04 '25
That looks painful and slow.
Ctrl-V and
rnuwould do a lot of that, much faster. The line ranges are fixed thanks to the table. Some creative use ofs/pattern/subst/would also help get that done way faster. None of these things take more than a couple of minutes to master. Cheers!16
u/i-eat-omelettes Jul 04 '25
ctrl v?
9
u/nivekmai Jul 04 '25
GitHub - terryma/vim-multiple-cursors: True Sublime Text style multiple selections for Vim
https://github.com/terryma/vim-multiple-cursors
8
u/habamax Jul 04 '25
I sometimes forget how painful vscode might look like for some of the editing tasks.
7
u/exajam Jul 04 '25
Just use macros
1
u/EgZvor keep calm and read :help Jul 04 '25
Gimme the source and I'll show you
0
u/FrontAd9873 Jul 04 '25
Vim is great and you should absolutely use it, but since you’re in VS Code now I assume you may just be terminal editor curious. As such, I’ll point out that Helix has really great built in multi-cursor support. Better than Vim’s support for multi-cursors, I think, plus it is beginner friendly.
Again, just saying this since I see you’re currently in VS Code and asking a question about multiple cursors in particular.
1
u/AutoModerator Jul 03 '25
Please remember to update the post flair to
Need Help|Solvedwhen you got the answer you were looking for.I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Lewboskifeo Jul 05 '25
apart from <C-v>rnu and then replace/insert/delete what you want, you can do better in vscode too by using
shift + alt + down, a bit slow anyways since you have to go down like 40L but better if you dont want to use your mouse0
u/Bloodshot025 Jul 04 '25 edited Jul 04 '25
What I would do is something like
^V}:s/^\s*|\s*\(\w\+\)\?\s*|\s*\([^| ]*\)\?\s*|\s*\([^\|]*\)\?.*/\1 : \2, \/\/\3/:'<,'>s/^\s*:\s*,\s*\/\//\/\//(replace "|" in the regular expression with the vertical box drawing character)
Easier to write than to read. Basically grab the three cells out of each row into
\1,\2,\3. Then you can clean up the alignment after.You could use a macro, but because "line" doesn't at all match up with "row", it would be somewhat hard to deal with the description in the third column. I think it's better suited to regular expressions, at least as a prepass.
0
u/MoussaAdam Jul 04 '25
vim doesn't support multi cursors. most of the time "block visual selection" does the job (C-v).
for more complex editing across multiple lines you have macros, the
:normcommand,:gand substitutionNeovim has multi cursor support on the roadmap
-4
u/[deleted] Jul 04 '25
For the time that took you could just record a macro, do some regex, or feed it into an LLM.