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):
23
#1 - h_east (トロッコ6個) / @h_east

10/20/2011 at 12:36AM

23
#2 - You-Siang Lin / @yslinnctu

11/28/2011 at 02:07AM

23
#3 - Balkoth / @_Balkoth_

12/03/2011 at 09:50PM

23
#4 - no / @jt_vg

12/14/2011 at 06:10PM

23
#5 - Mihai Crăiță / @mihai_craita

12/18/2011 at 12:20PM

23
#6 - Federico Galassi / @federicogalassi

12/18/2011 at 09:58PM

23
#7 - Pei-Lun Lee / @ypcatw

12/21/2011 at 04:57AM

23
#8 - Justin Love / @wondible

12/24/2011 at 04:07PM

23
#9 - veki / @vx_ras

02/02/2012 at 10:59PM

23
#10 - Abdel Said / @abdelsaid

02/10/2012 at 11:53PM

23
#11 - Renat Aksitov / @Korvin79

03/01/2012 at 07:26AM

23
#12 - Sebastian Kusnier / @skusnier

05/05/2012 at 07:41PM

23
#13 - Rod Knowlton / @codelahoma

05/08/2012 at 01:28AM

23
#14 - Tim Chase / @gumnos

05/28/2012 at 12:36AM

23
#15 - Emile Swarts / @EmileSwarts

08/19/2012 at 06:37PM

23
#16 - Conner McDaniel / @connermcd

09/18/2012 at 05:53AM

23
#17 - Petro Тrouq / @zulolosi

08/22/2013 at 06:07PM

23
#18 - Charles H. Leggett / @cleggett

11/05/2013 at 04:58PM

23
#19 - John Braxler / @braxler

05/01/2014 at 02:26PM

23
#20 - LC / @leeren

08/10/2014 at 07:29AM

23
#21 - Jon Krause / @jkrause314

01/27/2016 at 11:02PM

23
#22 - Turkey Man / @lvturkeyman

11/27/2017 at 04:42PM

23
#23 - Evgeny`s Kindle / @EvgenyKindle

05/02/2018 at 07:10AM

23
#24 - Miłosz Łakomy / @foobar01123

05/16/2020 at 05:23AM

23
#25 - blabla zincou / @BZincou

04/14/2022 at 08:32PM

23
#26 - Jean George / @JeanGeo20504212

05/02/2022 at 12:32AM

23
#27 - russellzhaomao / @russellzhaomao

06/01/2022 at 08:15AM

23
#28 - Qing Liu / @poeminlash

08/10/2022 at 05:34AM

23
#29 - Peppa Pig / @PeppaPi95550250

07/03/2024 at 07:32AM

23
#30 - nickGPT / @nickandbro

08/28/2024 at 10:30PM