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):
34
#91 - Dave@Highgroove / @HighgrooveDave

05/23/2012 at 03:07AM

34
#92 - Tyler / @tylerbindon

04/03/2013 at 08:28PM

34
#93 - Xelrifos / @Xelrifos

02/23/2014 at 12:38PM

35
#94 - Camac / @gregorbyte

12/12/2011 at 06:21AM

35
#95 - sebtyp / @sebtyp

12/15/2011 at 07:41PM

35
#96 - Dj Vimgolf / @dj_vimgolf

12/31/2011 at 02:30AM

36
#97 - Nolen Royalty / @NolenRoyalty

04/21/2012 at 03:41AM

37
#98 - Travis Jeffery / @travisjeffery

12/02/2011 at 11:15PM

37
#99 - Jonathan Lozinski / @jlozinski

04/21/2012 at 04:59PM

38
#100 - Mislav Marohnić / @mislav

12/05/2011 at 03:18PM

38
#101 - Stephen Crosby / @stevecrozz

12/20/2011 at 09:53PM

38
#102 - Ben Friedland / @bfriedland174

05/22/2012 at 03:59AM

39
#103 - Joel Bradshaw / @cincodenada

11/23/2011 at 10:23PM

39
#104 - learninghang / @learninghang

04/14/2012 at 07:52AM

40
#105 - Ernestas / @ernestas

10/19/2011 at 04:15PM

40
#106 - Joe Nerdan / @JoeNerdan

12/15/2011 at 08:09PM

40
#107 - @naught101@mastodon.social / @naught101

03/14/2012 at 04:00AM

41
#108 - Panino Matic / @paninomatik

10/27/2011 at 05:33AM

41
#109 - Michael Norton / @DocOnDev

01/18/2012 at 12:50AM

42
#110 - Vitor Eiji / @vitoreiji0

10/21/2011 at 01:56PM

43
#111 - RusAlex Pletnev / @RusAlexander

11/14/2011 at 06:22PM

43
#112 - Jacob Vosmaer / @jacobvosmaer

06/03/2012 at 02:41PM

43
#113 - utopiah / @utopiah

06/09/2012 at 08:49AM

44
#114 - Raphaël De Giusti / @raphdg

10/26/2011 at 07:28AM

44
#115 - Sergi Sorribas / @lerovitch

12/22/2011 at 04:19PM

44
#116 - Tara Bass / @tara_bass

12/23/2011 at 06:25AM

45
#117 - Jed Hurt / @meekish

10/19/2011 at 03:00PM

45
#118 - Mark Reed / @markjreed

10/22/2011 at 10:44PM

45
#119 - Salleyron Julien / @juguul

01/11/2014 at 09:51PM

45
#120 - Justin Knag / @justinknag

08/28/2014 at 05:17PM