PHP Array Syntax -> MailChimp Merge Syntax
I recently needed to send an e-mail to our marketing department listing allowed merge tags for our MailChimp campaigns. The allowed merge tags were determined from a PHP array in one of our PHP classes. I transformed the PHP class to MailChimp's syntax and sent the e-mail. It was, however, a long, laborious process. I'm still fairly new to Vim and would love to see how an expert Vim user would tackle one of my own, real-world problems. Thanks and have fun!
Start file
$allowed = array("PIN", "Prefix", "LastName", "FirstName", "MiddleName", "Address1", "Address2", "City", "State", "Zip", "Country", "phone", "mobile", "Email", "MothersMaiden", "security1_id", "security1_answer", "security2_id", "security2_answer", "BirthDate", "flag1", "DriversLicense", "gender");
End file
*|PIN|* *|Prefix|* *|LastName|* *|FirstName|* *|MiddleName|* *|Address1|* *|Address2|* *|City|* *|State|* *|Zip|* *|Country|* *|phone|* *|mobile|* *|Email|* *|MothersMaiden|* *|security1_id|* *|security1_answer|* *|security2_id|* *|security2_answer|* *|BirthDate|* *|flag1|* *|DriversLicense|* *|gender|*
View Diff
1,5c1,23 < $allowed = array("PIN", "Prefix", "LastName", "FirstName", "MiddleName", < "Address1", "Address2", "City", "State", "Zip", "Country", "phone", "mobile", < "Email", "MothersMaiden", "security1_id", "security1_answer", < "security2_id", "security2_answer", "BirthDate", < "flag1", "DriversLicense", "gender"); --- > *|PIN|* > *|Prefix|* > *|LastName|* > *|FirstName|* > *|MiddleName|* > *|Address1|* > *|Address2|* > *|City|* > *|State|* > *|Zip|* > *|Country|* > *|phone|* > *|mobile|* > *|Email|* > *|MothersMaiden|* > *|security1_id|* > *|security1_answer|* > *|security2_id|* > *|security2_answer|* > *|BirthDate|* > *|flag1|* > *|DriversLicense|* > *|gender|*
Solutions
The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!
Check out these helpful resources to improve your Vim skills... Game on.
#150 Ryan / @Rdgy567889 - Score: 246 - 10/01/23 @ 10:42
dt(4jf)D04j4kxjxxj2xj2xj2x"s<Esc>:s/ <Left><Left><Left>%<Right><Right> <BS>/<BS> /\n<CR><Esc>u:s/<BS><BS>%s/ /\n/g<CR>u/"<BS>:s/ <BS><BS><BS><BS><BS>:s/ /<Left><Left><Left><Left>%<Right><Right><Right><Right>\r/g<CR>kkkdd4j6kdd13kdd:s/"//g<Left><Left><Left><Left><Left><Left>%<CR>/<BS>:s,<BS><BS>%s/,//g<CR>j<C-V>GGggI*|<Esc><Esc>:s/&<BS>^<BS>*<BS>$<Left>,<BS>.<Left><Left><Right><Right><Right><BS><BS>\r/<Left><Left><Left><Left><Left>%<Right><Right><Right><Right><BS>n<Right>|*/g<Left><Left><Left><Right>}<BS>\n<CR>u"<Esc>jk:s<BS>$<BS>%s/^<BS>$.<BS><BS>.$/.<BS><BS><BS><BS><BS><BS>norm A|*<CR>:wq<CR>
0 comments