The sickest regex I've ever used so far
Had a bunch of attributes for ui widgets (same thing as properties in css basically) with c99-style struct initializers that all looked like this:
Then I finally got fed up with these long definitions, and decided to just convert them into the following macro form:
So basically the same but shorter. And the following command does just that:
Pretty sick for a command that was actually used and not just theorized!
Though obviously the bigger question is why I've tolerated the three-line version for so long...
2025-05-07 · 1 year ago · 👍 ResetReboot, Half_Elf_Monk, Saltbearer · 😄 1
4 Comments ↓
🌲 Half_Elf_Monk · 2025-05-07 at 21:30:
I love it when something like this comes together and works the way it should. Impressive. :)
👾 jecxjo · 2025-07-19 at 22:48:
I think macros are the best part of vim to show people interested in the editor. Half of my repeated edits are done as regex and the other half is macros I create on the fly. It is the reason I can never leave, my brain defaults to solution this way.
🌧️ candycanearter [✍️] · 2025-07-21 at 12:25:
i personally dont use macros that much, but i have been meaning to learn how to use them lately... i love the hjkl movement of vim, and the yank/delete stuff
👾 jecxjo · 2025-07-21 at 15:55:
The first step you need to get down is navigation. If you aren't navigating your document in more specific strokes then you're not ready for macros. When I navigate the document its all in words and lines and find the next/previous character.
Once you have that down then you can start recording steps as you fix the first instance. Move to the second and play it. The cool thing is that eventually you can start using it in code creation as well. I will often just make a list of all the variables and then record a macro where I convert the single word into the private member variable as well as the getter and setter functions. Then just select the list of names and apply and bam you have your class