Comment by ๐ฒ Half_Elf_Monk
Re: "The sickest regex I've ever used so far"
I love it when something like this comes together and works the way it should. Impressive. :)
2025-05-07 ยท 1 year ago
3 Later Comments โ
๐พ 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
Original Post
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: [preformatted] Then I finally got fed up with these long definitions, and decided to just convert them into the following macro form: [preformatted] So basically the same but shorter. And the following command does just that: [preformatted] Pretty sick for a command that was actually used and not just...