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):
27
#61 - peter reisinger / @PeterReisinger

12/30/2011 at 05:54PM

27
#62 - Woojung Kim 김우중 / @_kimwz

07/16/2013 at 02:43AM

27
#63 - Oliver Christ / @0liverChrist

10/11/2013 at 09:23PM

27
#64 - Matt Robbins / @mcrmfc

11/24/2014 at 04:13PM

27
#65 - Mauro Persano / @fzort

05/25/2015 at 01:25AM

27
#66 - RockerZZY / @rocker_zzy

06/18/2020 at 12:40AM

28
#67 - Alex David / @alexd_me

03/27/2012 at 06:01PM

28
#68 - Mauro Persano / @fzort

11/22/2014 at 03:42PM

29
#69 - Jose Gutierrez / @Jogusa

09/20/2014 at 07:01PM

29
#70 - Daniel / @Daniel00288663

04/04/2017 at 09:34AM

30
#71 - Federico Bond / @federicobond

07/18/2012 at 06:13AM

30
#72 - Marcin Szamotulski / @me_coot

11/28/2012 at 08:16PM

30
#73 - Gurukandhamoorthi / @Gurukandhamoor1

08/04/2017 at 06:05PM

30
#74 - tp971 / @tp971

01/30/2019 at 08:31PM

31
#75 - brett / @brettyukich

09/22/2013 at 08:52PM

31
#76 - CJ Avilla / @cjav_dev

11/18/2014 at 05:17PM

32
#77 - Scott Wehrenberg / @swehren

05/18/2012 at 02:35PM

32
#78 - RobertT / @techrt2050

07/16/2013 at 05:24AM

32
#79 - cj / @cj01101

08/20/2013 at 10:09PM

32
#80 - James / @Dronak

09/21/2014 at 02:05AM

33
#81 - Jer Wilson / @superjercom

10/28/2011 at 07:00AM

33
#82 - Pavlo Klets / @p01nt

10/28/2011 at 09:12AM

33
#83 - Daniel Hjerth / @danielhjerth

11/09/2011 at 06:02PM

33
#84 - Conrad Indiono / @indygemma

12/12/2011 at 10:48AM

33
#85 - Peter Anselmo / @peter_anselmo

03/02/2012 at 06:02PM

33
#86 - ぷりケツにるぽ / @nillpo

01/08/2015 at 02:26AM

33
#87 - TheProgrammer971 / @tp971

03/14/2015 at 02:39AM

34
#88 - Neal Lindsay / @neall

11/12/2011 at 05:50PM

34
#89 - Matt Woelk / @MattWoelk

11/13/2011 at 04:30AM

34
#90 - not so punk :] / @notsopunk

03/31/2012 at 07:48AM