Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 4e9edef5cef4c50001000007

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.

Unlock 149 remaining solutions by signing in and submitting your own entry
#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


Created by: @meekish

150 active golfers, 545 entries

Leaderboard (lowest score wins):
24
#31 - vimja / @vimja666

10/29/2011 at 07:17AM

24
#32 - A / @tndrnt

12/10/2011 at 02:20PM

24
#33 - Vasil Sakarov / @vsakarov

12/28/2011 at 10:06AM

24
#34 - Xavier Nayrac / @lkdjiin

01/02/2012 at 04:50PM

24
#35 - Grigoriy Glushko / @grinderrz

02/17/2012 at 09:52AM

24
#36 - ise0615 / @ise0615

05/05/2012 at 10:52AM

24
#37 - Kerson Hsiao / @KersonHsiao

07/03/2012 at 03:45PM

24
#38 - Urtica dioica / @udioica

12/12/2012 at 05:40AM

24
#39 - Trevor Powell / @DoomedBunnies

03/20/2013 at 03:39AM

24
#40 - Marco Hinz / @_mhinz_

05/23/2013 at 11:04AM

24
#41 - Joonas Pihlajamaa / @jokkebk

02/23/2014 at 12:27PM

24
#42 - pftb12345 / @pftb12345

04/14/2015 at 11:06AM

24
#43 - DHM / @DHM29978992

05/15/2018 at 01:18AM

24
#44 - Mihai / @mihaicristiant

03/21/2019 at 11:56AM

24
#45 - Nick Yeow / @nickyeow

05/23/2019 at 02:18PM

24
#46 - vimgolfer / @vimgolfer7

10/12/2019 at 02:10PM

24
#47 - Lory / @Lory46845742

12/18/2019 at 02:26PM

25
#48 - Sergey Panin / @dixPro

11/08/2011 at 02:48PM

25
#49 - Dragan Cvetinovic / @kawkafi

11/20/2011 at 02:53PM

25
#50 - Gabriel Barta / @gbarta

12/02/2011 at 01:17PM

25
#51 - 0x5042 / @0x5042

12/09/2011 at 10:00PM

25
#52 - Jaime A. Sánchez / @jashbeta

12/23/2011 at 02:14AM

25
#53 - John Anderson / @opejn

12/24/2011 at 05:22AM

25
#54 - Bradd Szonye / @bszonye

07/15/2013 at 03:53AM

25
#55 - Quota / @Quotad

02/25/2014 at 08:43AM

25
#56 - Johannes Riecken / @rubystallion

01/15/2020 at 09:44PM

25
#57 - quemeraisc / @quemeraisc

05/20/2022 at 11:56AM

26
#58 - oliver mueller / @marcontwit

01/19/2012 at 09:36AM

27
#59 - Daniel Lundin / @danielundin

11/27/2011 at 08:56PM

27
#60 - Al / @96258

12/13/2011 at 12:52PM