3 ms·
Or, you could have hit qt, recorded your commands for the first change, and then replicated it for every other line with a simple @t, instead of redoing all the
by addicted 5y ago
Or, you could have hit qt, recorded your commands for the first change, and then replicated it for every other line with a simple @t, instead of redoing all the changes each time.
You don't have to learn command. You simply need to know how to edit with VIM.
And multi cursors only work for tabular data. The macro recordings can work for the entire document where you call a macro on a word/regex you searched for, for example.
- michaelmior 5y ago> multi cursors only work for tabular data There are several plugins which allow for more complex use of multiple cursors. * https://github.com/mg979/vim-visual-multi https://github.com/mg979/vim-visual-multi * https://github.com/terryma/vim-multiple-cursors https://github.com/terryma/vim-multiple-cursors
- knuthsat 5y agoI did record it with qd...q and repeated it with @d @@
- isaacremuant 5y agoVisual select and normal@t (assuming you saved it in t) is a good way to do it once for every line.
- continuational 5y agoNope, you can do find > select all to get multiple selections and edit those simultaneously.
- ThatGeoGuy 5y agoThis can be done in (neo)vim too, and with a bit better precision and less typing. :g/<regex>/<command> is the general form for [g]rabbing lines that match a regex and applying a command over them. You can also chain the command: :g/<regex1>/g/<regex2>/<command> I'll admit this isn't exactly something you intuit as easily as a drop-down menu, but (neo)vim does have tools for all these things out of the box.
- chrismorgan 5y agoHuh, somehow it’s never occurred to me to get binary logic by chaining :g and :v in this way—I’ve always done things in more complicated ways to make up for the lack.
- Scarbutt 5y agoMultiple cursors is for quick small editing tasks where you don't bother with a macro.
- devnonymous 5y agoI always find it strange that people recommend a different letter for the register when recommending macros. Why not just use `qq` and `@q` (with the added advantage that clearing the register is `qqq`) ?
- addicted 5y agoThe reason I don’t use q is it’s far too easy for me to accidentally hit a 3rd q when I didn’t intend to and not even realize it. This was a bigger problem when Apple decided to go with those butterfly keys.
- JamesSwift 5y agoYou probably are familiar, but for some newer folks: I almost always add a "go to beginning of next line" as the end of the macro so that I can e.g. 10@t to repeat it 10 times. Makes it much quicker than @t on each line once you have more than a few.