by curiousyogurt · 15y ago · 0 comments
q <macrokey> <do some stuff>; then q to stop recording. Then @<macrokey> to kick off the macro. Splendid.
The only problem is that they take a lot of practice before you get them right first time. After a while though, you learn to record them fairly quickly and they streamline your workflow. They also melt the faces of anyone pairing with you.
The best part is they get better with age. The more vim commands you know, the more opportunities you find for using them.
What do you find yourself macroing, generally?
$address = array(
'name' => '',
'line1' => '',
'line2' => '',
'state' => '',
'country' => '',
'postcode' => '',
);
That's a lot of commas and quotes etc. Nowadays I usually punch this into vim: name
line1
line2
state
country
postcode
Then I start on the first line and record a macro that wraps that word in quotes, then appends hashrocket, quotes, comma, and then moves to the next line. Run the macro 5 times with 5@<register> and the you get your array.