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

129 active golfers, 407 entries

Leaderboard (lowest score wins):
24
#31 - Urtica dioica / @udioica

12/12/2012 at 05:40AM

24
#32 - Trevor Powell / @DoomedBunnies

03/20/2013 at 03:39AM

24
#33 - Marco Hinz / @_mhinz_

05/23/2013 at 11:04AM

24
#34 - Joonas Pihlajamaa / @jokkebk

02/23/2014 at 12:27PM

24
#35 - pftb12345 / @pftb12345

04/14/2015 at 11:06AM

24
#36 - DHM / @DHM29978992

05/15/2018 at 01:18AM

25
#37 - Sergey Panin / @dixPro

11/08/2011 at 02:48PM

25
#38 - Dragan Cvetinovic / @kawkafi

11/20/2011 at 02:53PM

25
#39 - Gabriel Barta / @gbarta

12/02/2011 at 01:17PM

25
#40 - 0x5042 / @0x5042

12/09/2011 at 10:00PM

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

12/23/2011 at 02:14AM

25
#42 - John Anderson / @opejn

12/24/2011 at 05:22AM

25
#43 - Bradd Szonye / @bszonye

07/15/2013 at 03:53AM

25
#44 - Quota / @Quotad

02/25/2014 at 08:43AM

26
#45 - oliver mueller / @marcontwit

01/19/2012 at 09:36AM

27
#46 - Daniel Lundin / @danielundin

11/27/2011 at 08:56PM

27
#47 - Al / @96258

12/13/2011 at 12:52PM

27
#48 - peter reisinger / @PeterReisinger

12/30/2011 at 05:54PM

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

07/16/2013 at 02:43AM

27
#50 - Oliver Christ / @0liverChrist

10/11/2013 at 09:23PM

27
#51 - Matt Robbins / @mcrmfc

11/24/2014 at 04:13PM

27
#52 - Mauro Persano / @fzort

05/25/2015 at 01:25AM

28
#53 - Alex David / @alexd_me

03/27/2012 at 06:01PM

28
#54 - Mauro Persano / @fzort

11/22/2014 at 03:42PM

29
#55 - Jose Gutierrez / @Jogusa

09/20/2014 at 07:01PM

29
#56 - Daniel / @Daniel00288663

04/04/2017 at 09:34AM

30
#57 - Federico Bond / @federicobond

07/18/2012 at 06:13AM

30
#58 - Marcin Sza / @coot_

11/28/2012 at 08:16PM

30
#59 - Gurukandhamoorthi / @Gurukandhamoor1

08/04/2017 at 06:05PM

31
#60 - brett / @brettyukich

09/22/2013 at 08:52PM