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 131 remaining solutions by signing in and submitting your own entry
#132 Zee Spencer / @zspencer - Score: 168 - 01/18/12 @ 00:51
f(d0:s/\n<BS><BS>, /\n<CR>u<Up><Up><Up><Up>:<Up><Left><Left> <CR>u:<Up><Left><Left><BS><Right><Right>\<BS>/g<CR>u:<Up><Left><Left><Right><Right><Left><Left><Left><Left><Left><Left><Left><Left><Left>%<Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><CR>u<Up>:<Up><Left><Left><Left><Right>\r<Left><Left><CR>u<Up>:<Up><Left><Left><Left><Left><BS><BS><CR>ggx:%s/\r\r/\r/g<CR>:6d<CR>d0%<Esc>:%s/  //g<CR><BS><Down>i<BS><Esc>:18<CR>dd:%s/"<BS>^"/*|/g<CR>:%s/".*/|*/g<CR>ZZ

0 comments


Created by: @meekish

132 active golfers, 421 entries

Leaderboard (lowest score wins):
39
#91 - Joel Bradshaw / @cincodenada

11/23/2011 at 10:23PM

39
#92 - learninghang / @learninghang

04/14/2012 at 07:52AM

40
#93 - Ernestas / @ernestas

10/19/2011 at 04:15PM

40
#94 - Joe Nerdan / @JoeNerdan

12/15/2011 at 08:09PM

40
#95 - naught101 / @naught101

03/14/2012 at 04:00AM

41
#96 - Panino Matic / @paninomatik

10/27/2011 at 05:33AM

41
#97 - Michael Norton / @DocOnDev

01/18/2012 at 12:50AM

42
#98 - Vitor Eiji / @vitoreiji0

10/21/2011 at 01:56PM

43
#99 - RusAlex Pletnev / @RusAlexander

11/14/2011 at 06:22PM

43
#100 - Jacob Vosmaer / @jacobvosmaer

06/03/2012 at 02:41PM

43
#101 - utopiah / @utopiah

06/09/2012 at 08:49AM

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

10/26/2011 at 07:28AM

44
#103 - Sergi Sorribas / @lerovitch

12/22/2011 at 04:19PM

44
#104 - Tara Bass / @tara_bass

12/23/2011 at 06:25AM

45
#105 - Jed Hurt / @meekish

10/19/2011 at 03:00PM

45
#106 - Mark Reed / @markjreed

10/22/2011 at 10:44PM

45
#107 - Salleyron Julien / @juguul

01/11/2014 at 09:51PM

45
#108 - Justin Knag / @justinknag

08/28/2014 at 05:17PM

46
#109 - James Cash / @jamesnvc

10/19/2011 at 02:46PM

49
#110 - Chaiporn Jaikaeo / @cjaikaeo

11/27/2011 at 05:37PM

50
#111 - Iori ONDA / @120reset

12/14/2011 at 11:14AM

50
#112 - Angela Harms / @angelaharms

01/18/2012 at 12:52AM

51
#113 - Daniel Schierbeck / @dasch

12/06/2011 at 04:30PM

51
#114 - Tom Fetherston / @TomFetherston

01/18/2012 at 04:47AM

52
#115 - Roman Mašek / @romario333

10/24/2011 at 09:06PM

52
#116 - Gowtham Madhava / @gowthamgowtham

11/02/2011 at 05:34PM

52
#117 - Ethan / @ethanmiller

01/31/2012 at 04:17AM

52
#118 - Scott Schlesier / @sschlesier

02/22/2012 at 06:29AM

52
#119 - 無ん垢の叫び / @john_ababa

02/28/2012 at 04:04PM

52
#120 - Antoni Villalonga / @friki

08/15/2016 at 06:33PM